Types of class casting

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
  1. Up casting
  2. Down casting
Up 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.
Down casting
  • 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.

Leave a Reply

Your email address will not be published. Required fields are marked *