What is the output of the following code?
class Base {/*from w w w . j av a 2 s . c o m*/ static { System.out.print("STATIC:"); } { System.out.print("INIT:"); } } class MyClass extends Base { static { System.out.print("Here:"); } { System.out.print("There:"); } public static void main(String args[]) { new MyClass(); } }
c
When you instantiate a derived class, the derived class instantiates its base class.
The static initializers execute when a class is loaded in memory.
So the order of execution of static and instance initializer blocks is as follows:.