harendra singh rawat,bca 2nd year
TRANSCRIPT
11/26/2016
INFORMATION TECHNOLOGY
PROJECT REPORT
TOPIC WRAPPER CLASS AND
METHOD OF NENNESTING
SUMBITTED BY
Harendra Sing Rawat
JAVA PROGRAMING
BCA II&Year DEZYNE E’COLE COLLEGE
WWW.DEZYENEECOLE.COM
1 | P a g e
Project Report
On
JAVA PROGRAM
At
Dezyne E’cole College
Ajmer
Submitted to
Dezyne E’cole College
To words the
Practical Fulfillment on
BACHLAR OF COMPUTER APPLICATION
By
Harendra Singh Rawat
Dezyne E’cole Collage
106/10 civil lines, Ajmer
www.dezyneecole.com
2016-2017
2 | P a g e
ACKNOWLEDGMENT
I HARENDRA SINGH RAWAT, STUDENT OF DEZYNE E’ COLE COLLEGE,
ON? EXTREMELY GRATEFUL TO EACH AND EVERY INDIVIDUAL WHO HAS
CONTRIBUTED IN SUCCESSFUL COMPLETION OF MY PROJECT.
I EXPRESS MY GRATITUDE TOP WORD DEZYNE E’COLE COLLEGE FOR
THEIR. GUIDANCE AND CONSTANT SUPER VISION AS WELL AS FOR
PROVIDING THE NECESSARY INFORMATION AND SUPPORT REGARDING
THE COMPLETION OF PROJECT.
THANK YOU.
3 | P a g e
SYNOPSIS
This project is a minor, project made based on the theoretical
concepts of Java.
This project has made our basic concepts on Java Strong
4 | P a g e
Wrapper classes:-
As pointed out earlier, vectors cannot handle primitive data types like
int, float char, and double. Primitive data type may be converted into
object type 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:-
Simple Type Wrapper Class
Boolean Boolean
Char Character
Double Double
Float Float
Int Integer
Long Long
The wappera classes have 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
Method:-
Constructor Calling Conversion Action
Integer IntVal=new Integer(i); Primitive integer to Integer Object
Float FloatVal=new Float(f); Primitive float to Float Object
Double Doubleva=new Double(d); Primitive double to Double Object
Long LongVal=new Long(l); Primitive long to Long Object
5 | P a g e
Converting Object Number to Primitive Number Using type
Value() Method:-
Method Calling Conversion Action
Int i=IntVal.intValue(); Object to Primitive integer
float f=FloatVal.floatValue(); Object to Primitive float
Long l=Longval.longValue(); Object to Primitive long
Double d=DoubleVal.doubleValue(); Object to Primitive double
Converting Number to String Using to String()Method:-
Method Calling Conversion Action
str=Integer.toString(i); Primitive integer to string
str=Float.toFloat(f); Primitive float to string
str=Double.toDouble(d); Primitive double to string
str=Long.toLong(l); Primitive long to string
Converting String objects to Number Object Using the Static
Method valueOf()
Method Calling Converion Action
DoubleVal = Double.valueOf(str); Converts string to Double object
FloatVal = Float.valueOf(str); Converts string to Float object
IntVal = Integer.valueOf(str); Converts string to Integer object
LongVal = Long.valueOf(str); Converts string to Long object
Converting Numeric String to Primitive Number Using Parsing
Methods:-
Method Calling Conversion Action
Int I =Integer.ParseInt(str); Converts string to primitive integer
float f =Integer.ParseFloat(str); Converts string to primitive float
long l =Integer.ParseLong(str); Converts string to primitive long
double d =Integer.ParseDouble(str); Converts string to primitive double
6 | P a g e
Converting Primitive Number to object Number:-
Output:-
7 | P a g e
Converting Object Number to Primitive Number:-
Output:-
8 | P a g e
Converting Number to String:-
Output:-
9 | P a g e
Converting String Object to Numeric Object:-
Output:-
10 | P a g e
Converting Numeric String to Primitive Number:-
Output:-
11 | P a g e
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 the
feature to convert primitive data type to wrapper class type
automatically.
The compiler generates a cade implicitly to convert primitive type to the
corresponding wrapper class type and vise-versa. For Example, Consider
the Following Statements:
Doubled=98;
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.
Convert to the null type other than the identify conversion.
Convert from any class type C to any array type id C is not object.
12 | P a g e
Vector without using auto Boxing and Unboxing:-
Output:-
13 | P a g e
Vector with using auto boxing and unboxing:-
Output:-
Nesting of Methods:-
We discussed earlier that a method of a class can be called only by an
object of that class (or class its self, in the case of static methods) using
the dot operator. However, there is an exception to this at method 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(). The methods display() calls the methods largest() to deter mine
the largest of the two numbers and then display the result.
14 | P a g e
Nesting of Methods:-
Output:-
15 | P a g e
Nesting of Methods:-
Output:-
A method can call any number of methods. It is also possible for a called
methods to call mother method. That is, method may call method2, which
in turn my call method3.
16 | P a g e
THANK YOU