Answered! Java Programming Multiple Choice Question Which of the following statements is true?…

Java Programming Multiple Choice Question

Which of the following statements is true?

a. The code in a finally block is executed only if an exception occurs.

b. The code in a finally block is executed only if an exception does not occur.

c. The code in a finally block is executed only if there are no catch blocks.

d. None of the above are true.

Expert Answer

 The answers are as follows:

a) The answer is false : finally code gets executed whether exception occurs or not or whether it is handles or not.
b) The answer is false. The reason is stated above.
c) The answer is false as finally code has nothing to do with catch clause. try caluse is required to use finally caluse but catch is optional
Hence overall d) is true which states that none of the above is true.

Still stressed from student homework?
Get quality assistance from academic writers!