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.

Follow CodeGalaxy

Mobile Beta

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