You should read this:
Class Initialization (JLS) and
Class Instantiation (JLS)
A class is loaded basically the first time the class is referenced. Loading a class consists of creating the static context of the parent class, then building the static content of the class in question.
1) Lock the class
2) load the parent class - recursively run these steps on the parent class
3) assign static members and run static initializers
When the class is instantiated, and instance of the class is created, then:
1) The parameters to the constructor are processed
2) The parent constructor is called -> recursively applies these steps to the parent class
3) Instance members are created and initializers are run
4) The body of the constructor runs.
So when you run Class Z here is what happens:
Now Z is properly loaded, so main() can execute. When Z.main() is executed, you call new Z() so you go through the process of making a new instance of Z: