Java Inheritance

Inheritance is the process of acquiring the properties of one class object into another class object

and it allows the hierarchical classification. Inheritance also provides the facility of reusability.

In Java programming, a class that is inherited is called a superclass and class that does the inheriting is called subclass.     

                                                      If we want to inherit a class, we simply incorporate the definition of one class into another class by using extends keyword.

General form of a class declaration that inherits a super class

Types of Inheritance in Java

  1. Single level Inheritance
  2. Multi-level Inheritance
  3. Hierarchical Inheritance
  4. Hybrid Inheritance

Note: Java does not support multiple inheritance.        

Single level Inheritance

java single inheritance
Fig:java single inheritance

Multi level Inheritance

Multilevel Inheritance

Hierarchical Inheritance

java hierarchical inheritance
java hierarchical inheritance

Hybrid  Inheritance

java Hybrid  Inheritance
java Hybrid Inheritance

                 Write a program for single level inheritance.


Note: A subclass can access the public member of super class. A subclass can’t access the private member of super class.

Super Class Cant Access Sub Class Member

A sub class can access all the public member of super class but reverse is not true. Super class cannot access sub class data.


A sub class can’t access the private member of super class.   


program for Multi level inheritance.


Write a program for Hierarchical Inheritance.