I haven't posted much recently. Nobody I know posts much any more. I guess Twitter is the thing now. But this one is longer than 140 characters.
Q: Will the following Java program compile? Run without exceptions? If so, what does it print when run?
class Foo {
public static int i;
static { System.out.println("Foo");}
}
class Bar extends Foo {
public static int j;
static { System.out.println("Bar");}
}
public class Main {
public static int k = Bar.i;
public static void main(String[] args) {}
}
Lenient rules apply for this quiz: You are allowed to Google. You are allowed to read your copy of the Java Language Specification. But you do need to write down your answer before you compile the code.