What will be the output of the following code?

class Clazz {
        System.out.println("non-static init");
    public static void main(String a[]) {
        Clazz ob1 = new Clazz();
    static {
        System.out.println("static init");
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
Sign Up Now
or Subscribe for future quizzes