Hierarchical Inheritance in Java

(Last Updated On: February 28, 2019)

Learn Hierarchical Inheritance in java with example – When more than one classes inherit the same class is known as hierarchical inheritance.

Prerequisite:

Consider a Hierarchical Inheritance example,
A Teacher is expertise in the subjects java programming, physics and chemistry. So, The two departments i.e. computer department and science department can use the same teacher for teaching. He can teach java programming subject in computer department and physics and chemistry in science department.

Hierarchical Inheritance in java
Hierarchical Inheritance in java

Hierarchical inheritance Example

In this java program, Computer department and Science department classes both are child classes of Teacher class (parent class)

 

 

Output:

ComputerDepartment : Learn…
Java programming…

ScienceDepartment : Learn…
Physics…
Chemistry…