Ravi Prakash,BCA,2nd Year

Preview:

Citation preview

INFORMATION TECHNOLOGY

PROJECT REPORT

JAVA PROGRAMING

TOPIC

Wrapper classes& Nesting of

method

SUBMITTED BY

Ravi Prakash yadav

BCA 2nd year

Dezyne E’cole college

www.dezyneecole.com

pg. 1

Project Report

On

Java Programming

Dezyne E’cole College

Ajmer

Submitted

Dezyne E’cole College

Towards the

Partial Fulfillment on

Bachelors of computer application

By

Ravi Prakash Yadav

Dezyne E’cole College

106/10,civil lines, Ajmer

Tel-0145-2624679

www.dezyneecole.com

2016-2017

pg. 2

I Ravi Prakash, Student of Dezyne E’cole College, an externely grateful to each and

every individual who has contributed in successful completion of my project.

I express my gratitude towards Dezyne E’cole College for their guidance and

constant supervision as well as for providing the necessary information and

support regarding the completion of project.

Thank You

pg. 3

This project is a miner project made based on the

theoretical concepts of JAVA this project has made our basic

concept on java strong.

pg. 4

As pointed out earlier,vectors cannot primitive data types like int,float, char,and

double.Primitive data type may be converted into object types by using the

wrapper classes contained in the java,lang Package.Following table shows the

simple data types and their corresponding wrapper class types

Wrapper Classes For Converting Types

Simpal Type Wrapper Class

boolean Boolean char Character

double

float int Integer

long

The Wrapper Classes hava a number of unique methods for handling primitive

data type and object.They are listed in the following tables.

Converting Primitive number to object number using Constructor for

methods

pg. 5

Converting Object Numbers to Primitive Number Using typeValue()

Method

Converting Number to Sting Using to string()Method valueOf()

Method calling Conversion Action

Converting String Object to Numbers Object Using the Ststic Method

valueOf()

Method Calling Conversion Action

pg. 6

Converting Numeric String to Primitive Number Using Parsing Methods

Converting Numeric String to Primitive noumbers using parsing methods.

pg. 7

Converting Primitive number to object number

OUTPUT

pg. 8

Converting object number to Primitive number

OUTPUT

pg. 9

Converting numbers to String.

OUTPUT

pg. 10

Coverting string object to numeric object

OUTPUT

pg. 11

Coverting numeric String to Primitive number.

OUTPUT

pg. 12

Auto Boxing and Unboxing

The auto boxing and unboxing feature, introduced in J2SE 5.0, facilities the process of

handling primitive data type in collection we can use this feature to convert primitive data

type to wrapper class type automatically.

The compiler generates a code implicity to convert primitive type to the corresponding

wrapper class type and vise-versa. For example consider the following statement –

Double d=98.45;

double dbl=d.doubleValue();

Using the auto boxing and unboxing feature, we can rewrite the above code as:-

Double d=98.42;

double dbl=d;

How, the java compiler provide restrictions to perform the following conversions :-

Convert from null type to any primitive type

pg. 13

Vaetore without using auto bosing & unbosing:

OUTPUT

pg. 14

EXAMPAL

OUTPUT

pg. 15

Nesting of method

OUTPUT

pg. 16

Nesting of Methods :-

We discussed earlier that a method of a class can be called only by an object of that class (or

class itself, in the case of static methods) using the dot operator. However, there is an

exception to this. A methods can be called by using only its name by another method of the

same class. This is known as nesting of methods.

Program illustrates the nesting of methods inside a class. The class nesting defines one

constructor and two methods, namely largest () and display () calls the method largest () to

determine the largest of the two numbers and then displays the result.

Commented [B1]:

pg. 17

Exampal

OUTPUT

pg. 18

A method can call any number of methods.

It is also possible a called method to call another

Method. That is, method1 may call method2, which in turn may call method3.

pg. 19

Recommended