Different Types of Inheritance in Java

Inheritance is one of the powerful Object Oriented Concept, and improves re usability of the code.

Below are different types of inheritance
1. Single Inheritance or Simple Inheritance
This is simplest form of Inheritance, in which one class inherits members of another class. In Single Inheritance there exists one Base class and one Derived class.

Single Inheritance in Java
Single Inheritance

2. Multilevel Inheritance
In Multilevel inheritance, a Derived class is a Base class for some other class. As shown in below example class B is Derived from class A. And further class C is derived from class B. And class C can further be Base class of some other class, and there can be few more levels. Multilevel Inheritance example
multi level inheritance
multi level inheritance

Having too many Levels may adversely affect performance during run time.

Refer Inheritance in Generic class.

3. Hierarchical Inheritance
In Multilevel Inheritance, there is common Base class for more than one Derived class.
As shown in below picture class A is common Base class to classes B and C. Hierarchical Inheritance example

4. Hybrid Inheritance
Hybrid Inheritance has more than one inheritance. Actually this is combination of Multilevel, Single and Hierarchical Inheritance. Below is Hybrid Inheritance Example

Hybrid Inheritance in Java
Hybrid Inheritance in Java

You may also like to read:
Why multiple inheritance is not supported in Java?

One thought on “Different Types of Inheritance in Java”

Leave a Reply