Inheritance is property in which the property of a parent class(Superclass) is passed on to child class(Subclass). For example
class Abc{ —– This is a class
int a; —— This is a variable
public void abc(){} — Methods
}
class Xyz extends Abc —–(Extend is the keyword, Xyz is the subclass which inherits the properties of ABC parent class.)
{
public static void main (String args[]) ——This is a method
{
Abc a= new Abc(); —— This is object creation where ‘a’ is the reference variable or object name
}
}