Types of Inheritance
1. Introduction
Inheritance allows classes to acquire properties and behaviors of other classes.
Java supports several forms of inheritance, but not all types seen in other OOP languages (like C++).
Understanding different types of inheritance helps in designing clear and logical class structures.
2. Types of Inheritance
Java supports the following types:
- Single Inheritance
- Multilevel Inheritance
- Hierarchical Inheritance
- Hybrid Inheritance (Supported through interfaces)
Java does not support:
- Multiple inheritance through classes
(to avoid ambiguity known as the “diamond problem”)
Let’s explore each supported type in detail.
3. Single Inheritance
A class inherits from only one parent class.
A
│
└── BExample:
class A {
void show() {
System.out.println("A show");
}
}
class B extends A {
void display() {
System.out.println("B display");
}
}Here, class B inherits from class A.
4. Multilevel Inheritance
A class is derived from another subclass, forming a chain.
A
│
└── B
│
└── CExample:
class A {
void m1() { }
}
class B extends A {
void m2() { }
}
class C extends B {
void m3() { }
}Class C inherits from B and indirectly from A.

5. Hierarchical Inheritance
Multiple classes inherit from the same parent class.
A
/ | \
B C DExample:
class Animal {
void eat() { }
}
class Dog extends Animal {
}
class Cat extends Animal {
}
class Horse extends Animal {
}All subclasses share common methods from Animal.
6. Hybrid Inheritance
Hybrid inheritance is a combination of two or more types of inheritance.
Java supports hybrid inheritance using interfaces, not classes.
Example:
A Interface X
│ │
B │
\ /
CExample with interfaces:
interface X {
void m1();
}
class A {
void m2() { }
}
class B extends A implements X {
public void m1() { }
}Java prevents multiple inheritance of classes to avoid ambiguity but allows hybrid patterns using interfaces.
7. Multiple Inheritance (Not Supported in Classes)
Java does not allow:
class C extends A, B; // ERRORReason: Diamond Problem
If both A and B have the same method, the JVM cannot decide which version C should inherit.
Java solves this by:
- Allowing multiple inheritance through interfaces, not classes.

8. Summary Table of Inheritance Types
| Type | Supported in Java (Classes) | Supported via Interfaces | Description |
|---|---|---|---|
| Single | Yes | Yes | One parent, one child |
| Multilevel | Yes | Yes | Chain of inheritance |
| Hierarchical | Yes | Yes | One parent, many children |
| Hybrid | No | Yes | Combination (using interfaces) |
| Multiple | No | Yes | Supported only via interfaces |
9. Real-World Examples
Single Inheritance
Vehicle → CarMultilevel Inheritance
Person → Employee → ManagerHierarchical Inheritance
Account → SavingsAccount, CurrentAccount, LoanAccountHybrid Inheritance (via interfaces)
Drivable, Electric → ElectricCar10. Summary
- Java supports single, multilevel, hierarchical, and hybrid (via interfaces) inheritance.
- Java does not support multiple inheritance of classes to avoid ambiguity.
- Interfaces provide flexibility for hybrid and multi-type inheritance.
- Understanding these forms helps in designing cleaner class structures and relationships.
This completes Types of Inheritance in Java.
Written By: Shiva Srivastava
How is this guide?
Last updated on
