A subclass inherits all the fields of its superclass. Therefore, when a subclass constructor initializes class properties, inherited superclass properties must also be initialized. To ensure this, the subclass constructor first calls the superclass constructor, and then continues with its own constructor.
Z
extends Y
Y
extends X
, new Z()
Z()
, Y()
, X()
. X()
? java, , no-argument . , X
X()
. x1
, x2
x3
, 0
.
, main
Z()
, Z()
Y()
Y()
X()
. X()
x3
.