What is CLASS TYPE CASTING:
- Casting class type to another class type is known as class type casting.
- The class type casting done by following criteria.
1.Classes must have is a relationship(inheritance)
2.Class which we are trying to cast must have a property of class we have trying to cast
Types of class type casting
- Up casting
- Down casting
- Casting sub class to the super class type is known as upcasting
- Up casting can be done either implicit or explicit.
- Implicit casting done by compiler.
- Casting super class to sub class type is known as down casting
- Down casting should be done explicitly.
- Down casting is possible only on the already upcasted object.