In OOPs we can create the different
classes and functions according to our need and from the base class we can
derived the classes so, using the Inheritance the derived class can access the behaviour
and property of base class .Using
Inheritance the code reusability increases i.e if we want to create a new class
and there is already a class which include some of the data we want then we can
derive the new class from existing class and time requirement for process can
be reduced and debugging of code becomes easy.
There are five types of
Inheritance supported by Java:
Single Inheritance:
In a single inheritance, sub class
inherit the features of one superclass. In below figure 'A' is super class and
'B' is a sub class which is inheriting the features from super class.
fig. single Inheritance
Multilevel Inheritance:
In multilevel inheritance derived
class will be ineheriting a base class and it will act as a base class to
another class .Here 'A' is base class and 'B' is inheriting features from 'A'
and 'B' is base class as well for class'C'.
fig. Multilevel Inheritance
Hierarchical Inheritance:
In
Hierarchical Inheritance there is only one super class and multiple sub classes
inherit properties from single super class.
fig. Hierarchical Inheritance
Multiple Inheritance:
In Multiple Inheritance the one base
class can inherit properties from more than one super class. In Java we can
achieve Multiple Inheritance only with Interfaces
fig.
Multiple Inheritance
Hybrid Inheritance:
It is the mix of all types of
inheritance,Java does not support Hybrid Inheritance we can achieve it through
interfaces like multiple inheritance
fig. Hybrid
Inheritance
Amarja Chede(K 10)





Good concept 👍
ReplyDeleteGood concept 👍
ReplyDeleteWell explained 👍
ReplyDeleteVery understanding concept
ReplyDeleteGood work 👍
ReplyDeleteTopic is well explain..keep writing
ReplyDelete👍👍
ReplyDeleteVery nice ! Keep it up
ReplyDeleteInteresting
ReplyDeleteGood work
ReplyDeleteNice blog..
ReplyDelete👍👍👍👍
ReplyDelete