Answer: Inheritance is one of the most important concepts in OOPs. Using Inheritance we can derive one Class from another Class, basically we can bring the variables and functions from One Class into another Class, this way we can avoid the code duplication and achieve re-usability.
The existing Class is called as a Super Class and new Class will be called as Sub Class.
Example-
Super
class
:
public
class
Automobile(){
}
Sub
class
:
public
class
Car
extends
Automobile(){
}
Inheritance is applicable only for public and protected members. Private members can’t be inherited.