Type Casting Notes
Type Casting Notes
1. auto widening
Converting a smaller primitive type to the any of the
bigger primitive type is known as widening, since widening
is done automatically by compiler it is also called as
auto widening.
2.explicit narrowing
Converting the bigger primitive type to the smaller
primitive type is known as explicit narrowing. It should
be explicitly specified in the program using ()cast
operator by the use.
Up casting:
Converting an object of sub class to behave like any of
the super class type .
It is automatically done by compiler hence called auto up
cast.
Down casting:
Converting an upcasted object to behave like subclass
type.
It should be explicitly specified in the program by the
user.Down casting cannot be directly done .only an
upcasted object can be down casted.