How many lines does the following code output?
public class Main { private static void drive() { static { /*w w w . j a v a 2s. co m*/ System.out.println("static"); } System.out.println("fast"); } public static void main(String[] args) { drive(); drive(); } }
D.
A static initializer is not allowed inside of a method.
It should go on the class level rather than the method level.
The code does not compile, and Option D is correct.