<span style= "FONT-SIZE:32PX;" > Subclass a inherits the parent Class B, a A = new A (); The order in which the parent Class B constructor, parent class B static code block, parent Class B non-static code block, subclass a constructor, subclass a static code block, subclass a non-static code block executes.
correct answer: C
A parent class B static code block-> Parent Class B constructor-> subclass a static code block-> parent Class B non-static code block-></span>
<span style= "FONT-SIZE:32PX;" > Subclass a constructor-> subclass a non-static code block
B parent Class B static code block-> Parent Class B constructor-> parent class B non static code block-> subclass a static code block-></span>
<span style= "FONT-SIZE:32PX;" > Subclass a constructor-> subclass a non-static code block
C Parent Class B static code block-> subclass a static code block-> parent Class B non-static code block-> Parent Class B constructor-></span>
<span style= "FONT-SIZE:32PX;" > Subclass a non-static code block-> subclass a constructor
D parent Class B constructor-> parent Class B static code block-> parent Class B non-static code block-> subclass a static code block-></span>
<span style= "FONT-SIZE:32PX;" > Subclass a constructor-> subclass a non-static code block </span>
This problem, you can't understand the process of JVM instantiation object,
We're going to list this process:
1 The virtual machine first needs to load the. class file and load it into memory, and it will load the parent class of the instance (if the instance has a parent class, we have a parent class for good explanation)
2 Open space in heap memory, assign address
3 is then initialized with the attributes in the object.
4 The corresponding constructor is initialized
5 in the constructor, the parent class is initialized first
6 The Subclass property is initialized after the parent class initialization is complete
7 Subclass constructor to initialize
8 when initialization is complete, assign the address value to the reference variable.