How many lines of output does the following generate?
public class Main { static { //from w w w. j av a2s . c om System.out.println("any"); } { System.out.println("more"); } public static void main(String[] args) { new Main(); new Main(); } }
B.
The static initializer only runs once since statics are shared by all instances.
The instance initializer runs twice because we call the constructor twice.
Therefore, Option B is correct.