Execution condition configuration inherited method java

Call the constructor rules of inheritance under the following conditions:

Case 1: If the constructor subclass does not pass the super explicit call has parameters parent class constructor, there is no explicit calls itself other constructors by the this, the system will default constructor with no arguments to call the parent class to . In this case, write do not write "super ();" statement, the effect is the same.

Case 2: If the subclass constructor argument constructor methods super explicitly by calling the parent class, it will perform the corresponding parent class constructor, without performing the parent class constructor with no arguments.

Case 3: If explicit calls itself Constructor for other subclass by this, the above two rules apply in a corresponding constructor.

Of particular note is that if there is multi-level inheritance, when you create a subclass object, the above rules several times to a higher level parent application, has been up to no-argument constructor to perform top-level parent class Object class.

Guess you like

Origin www.cnblogs.com/Yanss/p/11687205.html