Inheritance is one of the cornerstones of object oriented programming, because it allows creating class hierarchy. In terminology of Java the class which is inherited is called the
“super class” and the class that does the inheriting is called “sub class”.
When a sub class is inherits a super class, it inherits the state and the behavior from all of its ancestors.
Lets say, the object of A has var1 and M1. The class A is inherited by class B, that why the object of class B contains the properties and methods of class A. The class is inherited by class C, so the object of class C contains the methods and properties of class B.
Inheritance in Java
Until now you have learned the concepts of Inheritance, now before implementing it, it is important to note that Java does not support multiple Inheritance, although multiple inheritance of interfaces are allowed.
To inherit a class, you simply incorporate the definition of one class into another using the extends keyword. Read full story »