- Class acquired property of another class is known as inheritance.
- Class can inherit from any class using extends keyword
1. Single level inheritance
- in single level inheritance subclass inherit from only one super class
2. Multilevel inheritance
- subclass inherit from super class which inherit from another superclass
3. Multiple inheritance
- java does not support multiple inheritance
- In this type of inheritance subclass inherit more than one super class
4. Hierarchical inheritance
- in this type of inheritance property of super class is inherited to
more than one sub class
- To avoid ambiguity java does not support multiple inheritance.
- If you want to call more than one super class constructor then you
require two super() statement and multiple super is not allowed so multiple
inheritance is not support in java.
i.e.consider a scenario where A, B, C and Dare four classes, the b and c class inherits Aclass. now consider d inherit b and c.
now b and c both class have common property of a now there is ambiguity at class d which property should came in d class.
so java does not support multiple inheritance.