Overriding

When a child class has same method as that of a parent class, that method is said to override the parent's method.

How can it be achieved?

  • Method must have same name as parent
  • Same parameter as parent
  • Return type must be same or have an IS-A relationship with parent method's return type Covariant Return Type.
  • Overridden method should not be more restrictive than parent method.

Children
  1. Exception declaration with Method overriding

Backlinks