The static
block is executed before the main
starts, so x
get printed.
Then we enter the main, and we call
new Sequence().go();
Which calls the Sequence
constructor. As per the static block, before The Sequence
constructor gets called (so before a new Sequence
object gets initialized), the instance block (the one written within the braces) gets executed, so y
gets printed.
Then the constructor call prints c
.
In the end, the go()
method gets called on the newly created object, so g
gets printed.
So the full output will be
x y c g