This content originally appeared on DEV Community and was authored by Ligouri S Tittus
Todays we discussed about inheritance.
One class(child class)gets the properties and behaviour (method)of the another class(Parent classes).
There 5 types of inheritance:
How it works diagram:
1. Single Inheritance → One class inherits from another.
Example:
2. Multilevel Inheritance → A class inherits from a class, which again inherits from another class (a chain).
Example:
3. Hierarchical Inheritance → Multiple classes inherit from the same parent class.
Example:
4.Multiple Inheritance (via Interfaces) → A class implements multiple interfaces (since Java doesn’t allow multiple inheritance with classes).
5. Hybrid Inheritance (via Interfaces) → Combination of two or more types of inheritance, achieved using interfaces.
This content originally appeared on DEV Community and was authored by Ligouri S Tittus