Typecasting means assigning an object of the superclass to an inherited class or vice-versa. There are two types of typecasting:
- upcasting: It assigns the object of the subclass to the superclass variable.
- downcasting: It assigns the object of the superclass to the subclass variable.