Casting
Integer Hierarchy
- long
- int
- short
- char
- byte
Floating Hierarchy
- double
- float
According to the above sequence the data types that are in the highest point have the highest power than lowers.Upcasting
We can understand upcasting simply as giving the subclass object to the super class variable.
In upcasting we cannot access higher types by lower types.
But lower types can be accessed by higher types.
Downcasting
Converting the sub class object added to the super class variable back into sub class variable.
This is simply giving the super class variable to the sub class variable.
For this,sub class object is used as parameter.
Comments
Post a Comment