Java upcasting and Downcasting
Upcasting and Downcasting
Upcasting
- The process of adding a sub-class object to a super-class reference variable is called upcasting.
A a = new B();
Downcasting
- The process of getting a sub-class object placed in a super
class variable back to the same sub-class reference is called downcasting.
B b = (B) a;
- The process of getting a sub-class object placed in a super
class variable back to the same sub-class reference is called downcasting.
B b = (B) a;
class variable back to the same sub-class reference is called downcasting.
Comments
Post a Comment