What is Inheritance :
- Child object behaving as a parent object.
How to Achive Inheritance :
- To achive inheritance, we should use extends keyword.
Types of inheritance :
- Single Inheritance
- Multilevel Inheritance
- Hierarchical Inheritance
- Hybrid Inheritance
- Multiple Inheritance
Single Inheritance :
- One child class inherits from one parent class.
Multilevel Inheritance :
- A class inherits from another class, and then another class inherits from that class. Example : Grandparent → Parent → Child
Hierarchical Inheritance :
- Multiple child classes inherit from a single parent class.
Hybrid Inheritance :
- Combination of two or more types of inheritance.
Multiple Inheritance :
if we use multiple inheritance, ambiquity problem will occure.
So Java does not support multiple inheritance. but it supports it via interfaces.
Top comments (0)