zzh

zzh

Class loading scenario: Loading order of static code blocks, constructors, and member variables in parent class and subclass.

Parent Class Person#

image

Subclass Student#

image

Execution Result#

image

Loading Order (Approximately)#

Parent class static code block -> Subclass static code block -> Parent class member variable -> Subclass member variable -> Parent class constructor -> Subclass constructor (The reason for the member variable check before the constructor is that the output of the constructor is not the default value of the member variable, but the assigned value)

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.