#132 if an exception is not caught the finally block will run and the rest of the method is skipped Answer:True I think the answer is False or it should have been if exception is caught. I am confused. This question is from Javaranch mock exam
Sadeep, The answer is true. Remember that the finally block always gets executed, no matter what. This will allow the programmers to do cleanup and freeup resources in one place which is guaranteed to execute. Look at the following code for better understanding.
Also note that the only statement that can cause finally to be skipped is the forced System.exit() call. Hope this helps, Ajith
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
posted 19 years ago
Should the question be modified to ask "if a RUNTIME exception is not caught the finally block will run...?" If a non-runtime exception is not caught, the compiler will complain about it before runtime.