---
title: "Inheritance and its types"  
description: "The process of acquiring properties of a base class is known as inheritance where the base class is a class whose properties are inherited. It is a ba"  
author: "Anonymous User"  
published: 2018-08-30  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/13095/inheritance-and-its-types  
category: "java"  
tags: ["java"]  
reading_time: 2 minutes  

---

# Inheritance and its types

## INHERITANCE

The process of acquiring properties of a [base class](https://www.mindstick.com/interview/2426/what-is-the-base-class-for-error-and-exception) is [known as](https://answers.mindstick.com/qa/31993/who-is-popularly-known-as-iron-man-of-india) inheritance where the base class is a class whose properties are inherited. It is a basic fundamental [property of object](https://www.mindstick.com/interview/23158/how-to-filter-array-using-predicate-on-a-custom-property-of-object-in-objective-c-ios)-[oriented programming](https://www.mindstick.com/interview/23571/what-is-the-difference-between-object-oriented-programming-and-object-based-programming).

## Inheritance syntax:

```
Class subclass-Name extends superclass-Name {   } 
```

## Types of Inheritance:

• Single-Level Inheritance

• Multi-level Inheritance

• [Multiple Inheritance](https://www.mindstick.com/forum/2519/java-multiple-inheritance)

• Multipath Inheritance

• Hierarchical Inheritance

• Hybrid Inheritance

## Single-level Inheritance:

In this inheritance single class is derived from the base class.

![Inheritance and its types](https://www.mindstick.com/mindstickarticle/5dfab149-87ef-485d-a8fc-37c0ce707af9/images/9fc5725c-4443-426e-8963-720cafb8fb00.png)\

```
Public class fruit { }Public class apple extends fruit {}
```

## Multi-Level Inheritance:

In this inheritance, more than one derived class is generated from another derived class.

![Inheritance and its types](https://www.mindstick.com/mindstickarticle/5dfab149-87ef-485d-a8fc-37c0ce707af9/images/90f184db-6fa4-4308-b016-e3e1462534a9.png)

```
Public class fruit {}Public class apple extends fruit {}Public class banana extends fruit {}
```

## Multiple Inheritance:

In this inheritance, a [derived class](https://answers.mindstick.com/qa/30686/what-is-a-base-class-and-derived-class) is generated from more than one base class.

![Inheritance and its types](https://www.mindstick.com/mindstickarticle/5dfab149-87ef-485d-a8fc-37c0ce707af9/images/ccc3ef8f-7bb5-4276-bdf3-2942e66f6948.png)

```
Public class mammal {}Public class wingedAnimal {}Public class Bat extends wingedAnimal, mammal{}
```

## Multipath Inheritance:

In this inheritance, a derived class is created from another derived class and the same base class of other derived classes.

![Inheritance and its types](https://www.mindstick.com/mindstickarticle/5dfab149-87ef-485d-a8fc-37c0ce707af9/images/a5b5df35-7454-4b10-a949-e9f48c2a1ae2.png)

```
Public class grandParent {}Public class parent1 extends grandParent {}Public class parent2 extends grandParent {}Public class child extends parent2, grandParent, parent2 {}
```

## Hierarchical Inheritance:

In this inheritance from a single base class, more than one derived class is generated.

![Inheritance and its types](https://www.mindstick.com/mindstickarticle/5dfab149-87ef-485d-a8fc-37c0ce707af9/images/d3fc78be-9daa-4410-93ca-b20b1be7b94a.png)

```
Public class employee {}Public class permanentEmp extends employee{}Public class temporaryEmp extends employee{}
```

## Hybrid Inheritance:

In this inheritance, it is a combination of more than one inheritance

![Inheritance and its types](https://www.mindstick.com/mindstickarticle/5dfab149-87ef-485d-a8fc-37c0ce707af9/images/49918c83-29f0-4150-bcd0-096c6f447031.png)

```
Public class person {}Public student extends person {}Public gateScore {}Public class pg-student extends student, gateScore {}
```

Advantages:

• It reduces redundancy.

• It increases readability.

• It provides [code reusability](https://answers.mindstick.com/qa/113734/how-does-object-oriented-programming-enhance-code-reusability-and-maintainability).

[Disadvantages](https://www.mindstick.com/blog/300577/advantages-and-disadvantages-of-web-3-0):

• If there are any changes made in parent class then the [child class](https://www.mindstick.com/forum/159389/how-to-remove-child-class-from-active-div) will also get affected.

Why multiple inheritances are not supported in java?

Due to the ambiguity problem, java does not [support multiple](https://www.mindstick.com/forum/159471/how-does-c-plus-plus-support-multiple-inheritance-and-what-are-potential-issues-associated-with-it) inheritances.

\

The real-life example of inheritance in java:

The real-life example of inheritance is the parent and its child.

\

---

Original Source: https://www.mindstick.com/articles/13095/inheritance-and-its-types

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
