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.

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Продолжайте изучать
тесты по Java
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты