Inheritance is one such concept where the properties of one class can be inherited by the other. It helps to reuse the code and establish a relationship between different classes.
In Java, there are two classes:
- Parent class ( Super or Base class)
- Child class (Subclass or Derived class )
Inheritance defines IS-A relationship between a Super class and its Sub class. extends and implements keywords are used to describe inheritance in Java.
- Single Inheritance
- Multilevel Inheritance
- Multiple Inheritance
- Hierarchical Inheritance
- Hybrid Inheritance
1.Single Inheritance :
2.Multilevel Inheritance:
3.Multiple Inheritance :
Having more than one Parent class at the same level is called multiple inheritance.
- Any class can extends only one class at a time and can’t extends more than one class simultaneously hence java won’t provide support for multiple inheritance.
- But an interface can extends any number of interfaces at a time hence java provides multiple inheritance support through interfaces.
4.Hierarchical Inheritance :
5.Hybrid Inheritance :
5.Hybrid Inheritance :
No comments:
Post a Comment