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");
}
}
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.
Login in to like
Login in to comment