1.Single Inheritance
2.Multiple Inheritance
3.Multilevel Inheritance
4.Hierarchical Inheritance
5.Hybrid Inheritance
In single inheritance, a class inherits implementation from only one super class. For example, if class B inherits from class A, class B will acquire all the members declared in class A.
B------>A(Parent)
In multilevel inheritance, a class inherits from a derived class (or subclass). For example, if class C inherits from class B, and class B inherits from class A, class C will acquire all the members declared in class B as well as all the members declared in class A.
C------->B------>A(Parent)
In hierarchical inheritance, many sub classes inherit from a single super class. For example, if classes B, C, and D inherit from class A, classes B, C, and D will acquire all the members declared in class A.
B------>A(Parent)C------>A(Parent)D------>A(Parent)
In multiple inheritance, a class inherits from several super classes. For example, if class C inherits from both class A and class B, class C will acquire all the members declared in class A as well as all the members declared in class B. Multiple inheritance is not directly supported by Java but through Interfaces one can.C------>A(Parent)C------>B(Parent)
A hybrid inheritance is a combination of any two of the above discussed inheritance types


3 comments:
Thank you, I have recently been searching for information about this topic for ages and yours is the best I have discovered so far.
Thank you for answering my exam question
I was stuck while preparing for my IT exams. This is an eye opener.
MASINDE ROBERT, KENYA
Post a Comment