Object Oriented Programming: Unit II: Inheritance, Packages and Interfaces

Type of Inheritance

OOPs

In single inheritance there is one parent per derived class. This is the most common form of inheritance.

Types of Inheritance

1. Single inheritance :

In single inheritance there is one parent per derived class. This is the most common form of inheritance. Refer Fig. 2.6.1.

2. Multiple inheritance :

In multiple inheritance the derived class is derived from more than one base class.

Java does not implement multiple inheritance directly but it makes use of the concept called interfaces to implement the multiple inheritance. Refer Fig. 2.6.2.


3. Multilevel inheritance :

When a derived class is derived from a base class which itself is a derived class then that type of inheritance is called multilevel inheritance.

For example - If class A is a base class and class B is another class which is derived from A, similarly there is another class C being derived from class B then such a derivation leads to multilevel inheritance. Refer Fig. 2.6.3.

4. Hybrid inheritance :

When two or more types of inheritances are combined together then it forms the hybrid inheritance. The following Fig. 2.6.4 represents the typical scenario of hybrid inheritance.

Review Questions

1. Explain in detail as how inheritance is supported in Java with necessary examples

2.Give an elaborate discussion on inheritance.

3. Explain in detail about various types of inheritance in java with neat diagra

Object Oriented Programming: Unit II: Inheritance, Packages and Interfaces : Tag: : OOPs - Type of Inheritance