Saturday, 5 September 2015

upcasting,downcasting,boxing,unboxing

Up casting.

Conversion of child data type into parent data type is
known as up casting.

Downcasting.

Conversion of parent data type into child data type is
known as downcasting.

To execute downcasting process there is always need of
type casting method.

General syntax for downcasting.

(type)expression

ob2=(class2)ob1;

Boxing

Conversion of value type into object data type is known as boxing.

Object behave like a universal data type because of boxing.

Object obj;
obj="helow";
obj="7.5";

unboxing

conversion of object data type into value type is called unboxing.
To executing unboxing process we always need of type casting.

doubled=convert.to Double (obj);

No comments:

Post a Comment