Thursday, June 28, 2007

Friday Java Quiz

My friend, Weiqi Gao, frequently posts a Friday Java Quiz . I ran into a situation today that seems like a good one.

Suppose you have the following two classes:

public class Test {
public static void main(String[] args) {
System.err.println( Foo.class.getName() );
System.err.println( "Testing, 1, 2, 3..." );
new Foo();
}
}

public class Foo {
static {
System.err.println( "Foo here." );
}
public Foo() {
System.err.println( "New Foo!" );
}
}


Without running this program, do you know what the output will be?