What will be the output of the following code?

class Clazz {
    {
        System.out.println("non-static init");
    }
    public static void main(String a[]) {
        System.out.println("main");
        Clazz ob1 = new Clazz();
    }
    static {
        System.out.println("static init");
    }
} 
Explanation
Static initialization blocks are executed when JVM loads the class, non-static inits are executed before class constructor is run.
Java
Java Quiz
Start Quiz

or Read more about Java Quiz

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback