Originally posted by Rippon Jalali:
The problem in the code below is that catch clause in the called method rethrows exception,and main method neither handles nor declares the exception.So shouldn't it give compiler error? but it is giving answer 3.
Can any body explain.
The compiler gave me an error when I did not declare a throws for main.
Additionally, you throw a new exception - not the one passed into the catch() ....
[message edit: finally executes no matter what, thus explains the printing of 3]
Usually what I do is just recode it each way and see what the compiler has to say about it.
[ January 07, 2007: Message edited by: Nicholas Jordan ]
[ June 09, 2007: Message edited by: Nicholas Jordan ]