When a class A inherits a Class B, Class B Inherits Class C, Class C inherits Class D, and then C, b; When the construct of a is executed, if there is a member variable, the member variable is executed, and finally the subclass inherits the parent class, and the subclass overrides a method of the parent class, and when the parent class constructs, The method called is not a method of the parent class, the method that is overridden by the subclass public class Structure {public static void main (string[] args) {new childd ();}} Class Father{father () {System.out.println ("construction 1111 of the parent class"); Write (); System.out.println ("Construction of the parent class 2222");} void Write () {System.out.println ("Write Method for parent class");}} Class CHILDD extends father{private int value = 1; Sleep s = new sleep (); Childd () {System.out.println ("Construction of the Subclass");} @Overridevoid write () {System.out.println ("Write Method value= for subclasses" +value),//When the parent class constructs an override method that calls the subclass, but the subclass has not yet started constructing, so value is the default value of 0} }class Sleep{sleep () {System.out.println ("Construction Sleep Method");}}
How Java is constructed