Java – Inheritance Explanation

Home/Java - Tutorial/Java - Inheritance/Java – Inheritance Explanation
Java – Inheritance Explanation 2017-08-09T11:43:21+00:00

Java Inheritance with Examples:

What is a Inheritance ?

The derivation of one class from another class is called Inheritance.

Type of inheritance :

A class that is inherited is called a super class.

The class that does the inheriting is called as subclass.

In above figure all class A is super class.

A subclass inherits all instance variables and methods from its super class and also has its own variables and methods.

One can inherit the class using keyword extends.

Syntax :

Class subclass-name extends super class-name


// body of class.


In java, a class has only one super class.

Java does not support Multiple Inheritance.

One can create a hierarchy of inheritance in which a subclass becomes a super class of another subclass.

However, no class can be a super class of itself.

Java Inheritance example program :


Output :
Multiplication is  30
Note : Private members of super class is not accessible in subclass,
           super class is also called parent class or base class,
           subclass is also called child class or derived class.

Prev Next