Inheritance is a concept where one class shares the structure and behavior defined in another class. Ifinheritance applied on one class is called Single Inheritance, and if it depends on multiple classes, then it is called multiple Inheritance.
OR
Inheritance is the property which allows a Child class to inherit some properties from its parent class. In Java this is achieved by using extends keyword. Only properties with access modifier public and protected can be accessed in child class.
Example:
public
class A { public String
parentName; public
int
parentage; public String
familyName; } public
class Child
extends
A{ public String
childName; public
int
childAge; public
void printMyName() { System.out.println(“ My name is “+ childName+” “
+familyName); } }
//In above example the child has inherit its family name from the parent class(A) just by inheriting the class.
Read More →