Atom Atom feed

Friday Java Quiz: What Will It Print

(This week's Friday Java Quiz is contributed by WeiqiGao.com correspondent Brian Gilstrap.)

View From The Fringe: 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?

Comments are directed to View From The Fringe.


BTW, the class in last week's quiz actually compiles and run fine on Linux systems. The $^A is a legal Java identifier. It is only on the less capable Windows systems that the resulting class file cannot be written to the file system. You would have the same problem with Java classes named COM, PRN, LPT1, COM1, etc.

Read more...

Tags :