Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!
We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!
Learn from Guru Rajesh Kumar and double your salary in just one year.
The process of deriving or making a new class from old class is known as inheritance .
syntax for decleration of child or new class :-
class childClassName extends ParentClassName
{
statement ;
}

- The code is being re-used from one class to another. We need not required to re-write the same thing again and again.
- Extensibility is one of the advantages of the inheritance in which we can extend the base class feature without making little or no changes to fulfill the business requirements.
- we don’t have to describe similar property or method in upcoming class we can extends all the property of parent class using inheritance.
Types of Inheritance
- Single Inheritance
- Multi-layer inheritance
- hierarchical inheritance
If single class is derived or made from one parent or old class is known as Single Inheritance
eg:-

In the multi-level inheritance, we will inherit the one base class into a derived class, and then the derived class will become the base class for another derived class.

In the hierarchical inheritance, we will inherit the one base class into multiple derived classes.
