The following applet verifies the call sequence of the parent class constructor, member variable initialization function, and non-static initialization block when calling the object constructor, regardless of static members and static initialization blocks.
Derive Member m1 = Member ("Member 1" "Initial Block ()" "Derive ()" Member m2 = Member ("Member 2" I = "getInt () "2" Base () "" Member () "+
The following conclusions are drawn: without considering static member initialization, when calling an object constructor, the program first calls the constructor of the parent class (you can use the super keyword to specify the constructor of the parent class, otherwise, the constructor without parameters is called by default and must be called in the first line of the constructor of the subclass ), the initialization functions and static initialization blocks of static member variables are executed in the code sequence. If the member variables do not specify a value, the default value is assigned, that is, the basic data type is 0 or false, and the object is null. Finally, the self-constructor is called.