Who can tell me the reason? question NO.:#132 question: if an exception is not caught the finally block will rnn and the rest of method is skipped. the answer is TRUE. my question: why skip the rest of method since not catch an exception?
Mike, you didn't HAVE an exception. The question is saying the if you have an exception, and that exception is not caught by a catch block, then the control immediately passes to finally and the rest of the commands after the exception are not executed. This is true. Try this:
The ArithmeticException is not caught. The output is: in finally (Bunch of exception messages complaining about dividing by zero)
"JavaRanch, where the deer and the Certified play" - David O'Meara
I knew all of that, but how I interpreted the question was: "If you have a try-catch-finally, and no exception occurs (an exception is not caught), then what happens."
But of course, duh, they are talking about "uncaught exceptions". The exception DOES occur, but your catch is either not the same, or a superclass of that exception type... in this case yes, the finally occurs and the method returns.
This kind of thing makes me frightened of going to write my Java Certification. It was a simple matter of the phrase "uncaught exception" (which I would have got immediately) versus "an exception is not caught" (which in *my* brain means "there is no exception *to be* caught". Further proof that everyone thinks differently. I really should have seen that.
Hopefully Ming will be back to see the real answer.