How many lines does the following code output?
public class Main { static { /*from w w w . j av a 2 s . c o m*/ System.out.println("static"); } private static void drive() { System.out.println("fast"); } public static void main(String[] args) { drive(); drive(); } }
C.
The static initializer is only run once.
The static method is run twice since it is called twice.
Three lines are printed, and Option C is correct.