Inheriting this feature is an important object-oriented concept, the advantage is to improve the reuse of code, saving development time.
inheritance in Java refers to extending functionality on the basis of a parent class, in which inheritance is divided into subclasses and parent classes.
A class has two important members: member variables and methods.
Java subclasses can obtain member variables and methods of the parent class through the keyword extends. A member of a subclass can have a variable of its own declaration definition, and also inherit from the parent class.
Characteristics of inheritance in Java:
1. Single root inheritance, only one node up, all classes inherit the root node is the Object class.
2.java does not support multiple inheritance. A class cannot inherit multiple classes at the same time * (multi-drink interfaces can be implemented).
3. When a subclass overrides a method of a parent class, the access permission cannot be lower than the parent class.
4. The class overrides the method of the parent class, the runtime system invokes the method implementation of the subclass override, and the subclass object calls the method implementation of the parent class. If you want to use the method of the parent class after overriding, use the keyword super.
Inheritance of Java Features