Inheritance
Inheritance is one of the key features of Object Oriented Programming. Inheritance provided mechanism that allowed a class to inherit property of another class. When a Class extends another class it inherits all non-private members including fields and methods. Inheritance in Java can be best understood in terms of Parent and Child relationship, also known as Super class(Parent) and Sub class(child) in Java language.
Inheritance defines is-a relationship between a Super class and its Sub class. extends and implements keywords are used to describe inheritance in Java.

class Vehicle
{
……
}
class Car extends Vehicle
{
……. //extends the property of vehicle class
}
Now based on above example. In OOPs term we can say that,
Vehicle is super class of Car.
Car is sub class of Vehicle.
Car IS-A Vehicle.
Purpose of Inheritance
It promotes the code reusability i.e the same methods and variables which are defined in a parent/super/base class can be used in the child/sub/derived class.
It promotes polymorphism by allowing method overriding.
Disadvantages of Inheritance
Main disadvantage of using inheritance is that the two classes (parent and child class) gets tightly coupled.
This means that if we change code of parent class, it will affect to all the child classes which is inheriting/deriving the parent class, and hence, it cannot be independent of each other.
Types of Inheritance
Java mainly supports only three types of inheritance that are listed below.
Single Inheritance
When a class extends to another class then it forms single inheritance
Multilevel Inheritance
When a class extends to another class that also extends some other class forms a multilevel inheritance
Hierarchical Inheritance
When a class is extended by two or more classes, it forms hierarchical inheritance.
NOTE : Multiple inheritance is not supported in java due to the following reasons.
#To remove ambiguity.
#To provide more maintainable and clear design.
We can get a quick view of type of inheritance from the below image.
