Java 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.
For additional information👇
Tags
details
Java Coding Best Practices
Java Development
Java Downcasting
Java for Beginners
Java Programming Tutorial
Java Type Casting
Java Type Conversion
Java Upcasting
Object-Oriented Programming