<< October 4, 2007 | Home | October 6, 2007 >>

Friday Java Quiz: Finally And Explicit Return

Just as I was ready to leave for the weekend, David asked a Java question on his way out. And I'll make it a Friday Java quiz. Again, as usual, answer the question without the help of the Java compiler.

Q: What will the following program print?

public class Foo {
  public static void main(String[] args) {
    try {
      System.out.println(1024);
      return;
    } catch (RuntimeException e) {
      System.out.println(2048);
    } finally {
      System.out.println(4096);
    }
  }
}
Tags :