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.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes