Java inheritance



1. Improve code reusability.

2. Let the class and the class have a relationship. Only with this relationship can we have the characteristics of polymorphism.

Java only supports single inheritance, not multiple inheritance, but can be implemented in many ways.

Because multiple inheritance is easy to bring security risks.

Java supports multi-layer inheritance, that is, inheritance system

To use a system, first refer to the description of the system’s parent class, because the parent class defines the common functions of the system.

By understanding the common functions, we can know the basic functions of the system.

In the specific call, the object with the most subclass should be created. Why?

First, it is possible that the parent class cannot create objects,

Second, creating subclass objects can use more functions, including basic and specific ones.

In a word: look up the function of the parent class and create the child class object to use the function.