Inheritance :
It is an mechanism in which the object occupies all the properties and behaviours of an parent object.
- Using the inheritance the information is more manageable and it is done in hierarchial order.
- The class which inherits the properties of the other class is called Subclass.
- Subclass is known as derived class or child class.
- The class in which their properties are inherited is called Superclass.
- Supercalss is known as base class or parent class.
Syntax of Inheritance :
class super {
. . . . . .
. . . . .
}
class sub extends super {
. . . . . .
. . . . . .
}
Types of Inheritance :
There are five types of inheritance which are supported by Java.
- Single Inheritance
- Multilevel Inheritance
- Hierarchial Inheritance
- Multiple Inheritance
- Hybrid Inheritance
Features of Inheritance:
The features of inheritance are :-
- Parameters.
- Annotations.
- Dimension values, tolerances and boundaries.
- Geometry tolerance
Advantages of Inheritance :
The advantages of Inheritance are :-
- It minimizes the amount of duplicate code in an application.
- It makes the code more flexible.
Disadvantage of Inheritance :
The disadvantges of Inheritance are : -
- It increases the time for the program to the levels of overloading.
- If two classes are get coupled in that one class is independent and another class is not independent.