Created on Fri Jan 15 2021 06:38:41 GMT+0000 (Coordinated Universal Time)
More creations to inspire you
In OOP, computer programs are designed in such a way where everything is an object that interact with one another. Inheritance is one such concept where the properties of one class can be inherited by the other. It helps to reuse the code and establish a relationship between different classes.
As we can see in the image, a child inherits the properties from his father. Similarly, in Java, there are two classes:1. Parent class ( Super or Base class)2.Child class (Subclass or Derived class )
Classification of inheritance into four groups
One class inherits the properties of another. Itenables aderived class to inherit the properties and behavior from a single parent class. This will in turn enable code re usability as well as add new features to the existing code.
When a class is derived from a class which is also derived from another class, i.e. aclass having more than one parent class but at different levels, such type of inheritance is called Multilevel Inheritance.
Whena class has more than one child classes (sub classes) or in other words, more than one child classes have the same parent class
Itis a combination of multipleinheritance and multilevel inheritance. Since multiple inheritance is not supported in Java as it leads to ambiguity, so this type of inheritance can only be achieved through the use of the interfaces.
This is all about