One: Related rules
(1) The constructor of theparent class must be called during the construction of the child class
(2) Subclasses can use Super (argumentlist) in their own construction methods to invoke the construction method of the parent class;
Use this (argumentlist) to call other constructor methods of this class
If you use Super (ArgumentList) to invoke the constructor method of the parent class, you must write the first line of the subclass construction method.
(3) If the constructor method of the parent class is not explicitly called in the constructor of the subclass, the constructor method is called without a parameter by default. Equivalent to executing super () By default in the subclass constructor method
(4) If the constructor of the parent class is not displayed in the subclass construction method, and no argument is constructed in the base class, the compilation does not pass.
Two: Look at an example
Execution Result:
Superclass
Subclass N =400
Java Fundamentals: Rules for constructing methods in inheritance