What will be printed out as a result of the following code compilation and execution?

public class A {
    {
        System.out.println("one");
    }

    public static void main(String[] args) {
        System.out.println("two");
    }

    static {
        System.out.println("three");
    }
}
Explanation
Static values initialization blocks are executed whenever the class is loaded for the first time regardless of the main(...) function. Usual initialization blocks are executed only after an instance of a given class is created. Therefore, the "one" string will not be printed out.

Следи за CodeGalaxy

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

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