Java Inheritance
Inheritance is one of fundamental features of Object Oriented programming. It is a powerful method to reuse code in a comprehensive manner. Once you learn this concept in Java you will be able to use this knowledge to learn other OOP Languages more easily.
Object is a Class?
Yes, there is a special class that is called "Object". This is the root class, and this is the only class that does not have a superclass. All other classes defined in Java are descended from the Object class.
Single Inheritance
Every class has one and only one direct superclass. In the absence of any other explicit superclass, a class is implicitly derived from Object. This model is called single inheritance. Notice that other languages like C++ and Python can use multiple inheritance model.
Java Class Hierarchy
Syntax:
We declare a subclass similar to a class in addition we specify the superclass using keyword: "extends". This is the idea to memorize: One subclass can extends a superclass like in this syntax pattern:
//define a demo standard class
public class ParentClass {
...
};
//define a subclass of ParentClass
public class ChildClass extends ParentClass {
...
};