Monday, April 18, 2011

Guess what is thrown

Today it happened we asked ourselves the following:

try {
 
    throw new NullPointerException();

} finally {

    throw new IllegalArgumentException();
}

Which one is going to be really thrown? Make your best guess and put in the comments section what you expected to happen and what really happened and why?

1 comments:

  1. As discussed via Facebook's chat, following the try/catch-finally "rules", no matter whats in try/catch block, always the finally block is executed before finishing the try/catch. So, the IllegalArgumentException will fly to the client.

    ReplyDelete