what is inheritance in java ? what are the types of inheritance?

 What is an Inheritance?

Inheritance: It is the object oriented programming (OOP)concept in which property of one class acquire by the another  class.


In java there are four type of inheritance.

  • Single inheritance 
  • Multilevel inheritance
  • Hierarchical inheritance
  • Hybrid inheritance
One more type of Inheritance is available in C . which is multiple inheritance.

Single Inheritance In this one child class is derived from one parent or base class.


Multilevel Inheritance: In this one class inherit from a derived class , thereby making this derived class the base class for new class.


Hierarchical Inheritance: In this multiple child classes are derived from one parent class.


Hybrid Inheritance: It is the combination of all inheritance.

There is a code written in java with an example of different type of inheritance.


Output after the execution










 


1 Comments

have you any doubt then ask.

Previous Post Next Post