zzh

zzh

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

Parent Class Person#

image

Subclass Student#

image

Execution Result#

image

Loading Order (Approximately)#

Parent Class Static Block -> Subclass Static Block -> Parent Class Member Variables -> Subclass Member Variables -> Parent Class Constructor -> Subclass Constructor (Member variables are checked before the constructor because the output of the constructor is not the default value but the assigned value)

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