Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Could someone help me with this? thanks ! 12.21 Suppose that statement 2 causes

ID: 3724754 • Letter: C

Question

Could someone help me with this? thanks !

12.21 Suppose that statement 2 causes an execption in the following statement: 1 tryf 2 statementl, 3 statement2; 4 statement3; 6 catch (Exceptionl exl) ( 8 finally ( 9 statement4; 10 11 statement5 Answer the following questions: . If no exception occurs, will statement4 be executed, and will statement5 be executed? . If the exception is of type Exception1, will statement4 be executed, and will statement5 be executed? If the exception is not of type Exception1, will statement4 be executed, and will statements be executed?

Explanation / Answer

(a) The statements in the finally block is always executed whether exception occurs occur or not. So, statement4 is executed. statement5 is after the try-catch-finally block, hence statement5 is executed.

(b) The statements in the finally block is always executed whether exception occurs occur or not. So, statement4 is executed.statement5 is after the try-catch-finally block, hence statement5 is executed.

(c)  The statements in the finally block is always executed whether exception occurs occur or not. So, statement4 is executed. After that the execution goes to the JRE and the exception is handled by the JRE. Hence, statement5 is not executed.