Inheritance is one of the four pillars of OOP in Java – alongside abstraction, polymorphism, and encapsulation. Understanding the types of inheritance in java is essential for any developer building modular, reusable, and maintainable code. Java supports five inheritance models, each serving a distinct design purpose.
This article covers every type of inheritance and its types in java with clear syntax, working code examples, and a comparison table – giving you everything you need to apply the right inheritance model in your projects.
But before we begin, you can brush up your knowledge on Java and its array by reading this HeroVired article on – What are Arrays in Java.
What is Inheritance in Java?
Inheritance in Java is a mechanism where one class acquires the properties (fields) and behaviours (methods) of another class. It models the is-a relationship – a Dog is-a Animal, a Puppy is-a Dog. The class being inherited from is the superclass (parent class), and the class doing the inheriting is the subclass (child class). Java uses the extends keyword to implement inheritance.

POSTGRADUATE PROGRAM IN
Multi Cloud Architecture & DevOps
Master cloud architecture, DevOps practices, and automation to build scalable, resilient systems.
Why use inheritance?
• Code Reuse: Write shared behaviour once in the parent class – all subclasses inherit it automatically
• Method Overriding: Subclasses can redefine parent methods to provide specialised behaviour (runtime polymorphism)
• Logical Organisation: Inheritance mirrors real-world taxonomies – making code structure intuitive and readable
• Extensibility: New classes can extend existing ones without modifying the original code (open/closed principle)
Types of Inheritance in Java
The different types of inheritance in java are determined by the number of parent and child classes involved and how the inheritance chain is structured. Java supports five inheritance types – four through classes and one exclusively through interfaces. The five types of inheritance in java with example are covered below.
1. Single Inheritance
Single inheritance is the simplest of all types of inheritance in java. A single child class inherits from exactly one parent class. This is the most commonly used inheritance model in Java and provides a clean, unambiguous class hierarchy.
Structure: Class B (child) extends Class A (parent). Class B gains all non-private fields and methods of Class A.
Property |
Detail |
Parent classes |
1 |
Child classes |
1 |
Complexity |
Low |
Java support |
Full (classes and interfaces) |
Use case |
Extending a base class with new specialised behaviour |
Syntax and Example:
|
Output: Dog is barking | Animal is eating
In this example, Dog inherits the eat() method from Animal without redefining it – a direct demonstration of code reuse through single inheritance.
2. Multilevel Inheritance in Java
Multilevel inheritance in java creates a chain of inheritance across three or more levels. Class C inherits from Class B, which itself inherits from Class A. This creates a linear ancestor hierarchy – each class adds to the behaviour of the one above it.
In a multilevel inheritance example in java: a Puppy is a Dog, and a Dog is an Animal. The Puppy class inherits from Dog, which in turn inherits from Animal. This is the classic example of multilevel inheritance – Puppy gains all methods from both Dog and Animal.
Property |
Detail |
Levels |
3 or more |
Chain direction |
Linear – A → B → C → … |
Java support |
Full |
Use case |
Progressively specialised class hierarchies (Vehicle → Car → ElectricCar) |
Key rule |
Each class inherits all accessible members from all ancestors up the chain |
Syntax and Example – Classic Multilevel Inheritance Example in Java:
|
Extended multilevel inheritance example in java – Vehicle hierarchy:
|
This second multilevel inheritance example in java shows a real-world vehicle hierarchy – a practical pattern used in automotive simulation systems, game engines, and manufacturing software. In each multilevel inheritance in java scenario, the deepest subclass has access to the cumulative behaviour of every ancestor in the chain.
3. Multiple Inheritance (via Interfaces)
Multiple inheritance is where a class inherits from more than one parent. Java does not support multiple inheritance through classes (to avoid the Diamond Problem), but fully supports it through interfaces. A class can implement any number of interfaces, gaining all their abstract method contracts simultaneously.
Note: Java intentionally omits multiple class inheritance to prevent ambiguity when two parent classes define the same method. Interfaces solve this because they define contracts (method signatures), not implementations – the implementing class always provides its own concrete method body. |
|
This is the standard pattern for achieving multiple inheritance in Java. Any number of interfaces can be combined – the implementing class is responsible for providing concrete implementations of all abstract methods. Default methods (Java 8+) in interfaces add another dimension, but explicit overriding resolves any conflicts.
4. Hierarchical Inheritance in Java
Hierarchical inheritance in java occurs when multiple child classes inherit from a single parent class. All subclasses share the common behaviour defined in the parent, while each can also add its own specialised methods. This creates a fan-out structure – one parent, many children.
Property |
Detail |
Parent classes |
1 |
Child classes |
2 or more |
Structure |
Fan-out – one parent, multiple children |
Java support |
Full |
Use case |
Shared base behaviour with specialised subclass implementations |
|
In this hierarchical inheritance in java example, Dog, Cat, and Bird all extend Animal and inherit eat(). Each subclass adds its own unique behaviour. This is one of the most common inheritance patterns in enterprise Java – for example, SavingsAccount, CurrentAccount, and FixedDepositAccount all extending a base BankAccount class.
5. Hybrid Inheritance in Java
Hybrid inheritance in java is a combination of two or more inheritance types – most commonly hierarchical + multilevel, or hierarchical + multiple. Java supports hybrid inheritance through interfaces when multiple inheritance is involved.
Hybrid inheritance in java via classes alone is limited to combinations that do not require multiple class parents (e.g., hierarchical + multilevel is fully supported). When multiple parents are needed, interfaces must be used – making interface-based hybrid inheritance the standard approach in production Java code.
|
Hybrid inheritance in java is the most flexible and complex model. It is commonly used in framework design – for example, Spring’s component hierarchy combines class-based hierarchical inheritance with multiple interface implementations to achieve modularity and testability.
Comparison: All Types of Inheritance in Java
Use this table as a quick reference for the different types of inheritance in java – covering structure, Java support status, and ideal use cases.
Type |
Structure |
Classes Involved |
Java Support |
Keyword |
Best Use Case |
Single |
A → B |
1 parent, 1 child |
Full |
extends |
Extending a single base class |
Multilevel |
A → B → C |
Chain of 3+ |
Full |
extends |
Progressive specialisation chains |
Multiple |
A + B → C |
2+ parents, 1 child |
Via interfaces only |
implements |
Combining unrelated capabilities |
Hierarchical |
A → B, A → C, A → D |
1 parent, many children |
Full |
extends |
Shared base with varied subclasses |
Hybrid |
Combination of above |
Varies |
Partial (interfaces for multi) |
extends + implements |
Complex framework or system design |
The types of inheritance in java with example covered in this guide map directly to this table. When choosing an inheritance model, the primary question is: how many parent classes does the child need? If one → single or hierarchical. If a chain → multilevel. If multiple capabilities from unrelated sources → interfaces.

82.9%
of professionals don't believe their degree can help them get ahead at work.
Why Java Does Not Support Multiple Class Inheritance
A common exam and interview question about inheritance and its types in java: why does Java prohibit multiple class inheritance? The answer is the Diamond Problem.
The Diamond Problem: Suppose Class C extends both Class A and Class B. Both A and B define a method display(). When C.display() is called, the compiler cannot determine which parent’s version to use – creating an irresolvable ambiguity.
|
Interfaces resolve the Diamond Problem by requiring the implementing class to override any conflicting default methods explicitly. This gives Java the flexibility of multiple inheritance without the ambiguity that makes it dangerous in C++.
Language |
Multiple Class Inheritance |
Solution for Ambiguity |
Java |
Not supported |
Use interfaces (implements multiple) |
C++ |
Supported |
Virtual inheritance (error-prone, complex) |
Python |
Supported |
MRO (Method Resolution Order – C3 linearisation) |
C# |
Not supported |
Use interfaces (same as Java) |
Kotlin |
Not supported |
Use interfaces with default methods |
Inheritance and Its Types in Java – Common Mistakes
Developers new to inheritance and its types in java frequently make these mistakes. Knowing them ahead of time prevents bugs that are difficult to trace:
• Attempting multiple class inheritance: Writing class C extends A, B is a compile error in Java. Use interfaces for multiple capability inheritance.
• Confusing multilevel and multiple inheritance: Multilevel = linear chain (A→B→C). Multiple = multiple parents (A+B→C). They are structurally different.
• Not calling super() correctly: In multilevel inheritance, if a parent constructor takes arguments, the child must explicitly call super(args) – otherwise a compile error occurs.
• Circular inheritance: A class cannot extend itself or form a cycle (A extends B, B extends A) – this is a compile error.
• Overusing inheritance over composition: Inheritance implies a strict is-a relationship. If the relationship is has-a, use composition instead. Overusing inheritance creates brittle, tightly coupled hierarchies.
• Private member visibility: Private fields and methods of a parent class are NOT inherited by the child. They exist in the child object but are not directly accessible – use getters/setters or protected access.
Conclusion
Mastering the types of inheritance in java – single, multilevel inheritance in java, multiple (via interfaces), hierarchical inheritance in java, and hybrid inheritance in java – gives you the structural foundation to design clean, reusable, and scalable Java applications.
The key takeaways: use single inheritance for straightforward parent-child extension; use multilevel inheritance in java for progressive specialisation chains; use interfaces for multiple inheritance; use hierarchical when many subclasses share a common base; and use hybrid when complex systems need combinations of the above.
Inheritance is a powerful tool, but always ask: is this a genuine is-a relationship? If yes, inheritance is the right model. If it’s a has-a relationship, prefer composition. This distinction is at the heart of clean OOP design in Java.
To build full production-grade Java expertise, explore the Certificate Program in Application Development powered by Hero Vired – covering Java, full-stack development, cloud, and more.
People Also Ask
What are the 5 types of inheritance in Java?
The five types of inheritance in java are: Single (one parent → one child), Multilevel (chain: A→B→C), Multiple (multiple parents → one child, via interfaces only), Hierarchical (one parent → multiple children), and Hybrid (combination of two or more types).
Does Java support multiple inheritance?
Java does not support multiple inheritance through classes to avoid the Diamond Problem. However, Java fully supports multiple inheritance through interfaces – a class can implement any number of interfaces simultaneously.
What is the difference between multilevel and hierarchical inheritance in Java?
Multilevel inheritance in java creates a linear chain: Class A → Class B → Class C (each inheriting from the one above). Hierarchical inheritance in java creates a fan-out: Class A is the parent of Class B, Class C, and Class D simultaneously. The key distinction is the direction of inheritance – linear chain vs. one-to-many.
What is an example of multilevel inheritance in Java?
A classic multilevel inheritance example in java: Animal → Dog → Puppy. Dog extends Animal and inherits eat(). Puppy extends Dog and inherits both eat() and bark(). A Puppy object can call all three methods – weep(), bark(), and eat() – demonstrating the cumulative inheritance chain.
What is hybrid inheritance and is it supported in Java?
Hybrid inheritance in java is a combination of two or more inheritance types. Java supports hybrid inheritance when no combination requires multiple class parents. When multiple class inheritance is involved, interfaces must be used instead – making interface-based hybrid patterns the standard approach in Java frameworks like Spring.
What is the most common type of inheritance in Java?
What are the types of inheritance in Java?
- Single-level inheritance.
- Multi-level Inheritance.
- Hierarchical Inheritance.
- Multiple Inheritance.
- Hybrid Inheritance.
Why Doesn’t Java Support Multiple Inheritance?
Why is Multiple Inheritance not allowed?
What is the major use of Multi-level Inheritance?
Updated on April 16, 2026
