Which keywords are required with a try statement?



Which keywords are required with a try statement?

 I. catch

II. finalize

III. finally

A. I only

B. II only

C. I or III, or both

D. None of these statements is required with a try statement.

Answer:

C. I or III, or both

Explanation:

A try statement requires a catch or a finally block. Without one of them, the code will not compile; therefore, Option D is incorrect.

 A try statement can also be used with both a catch and finally block, making Option C the correct answer. Note that finalize is not a keyword, but a method inherited from java.lang.Object.

Free Spring Boot Tutorial - 5 Hours Full Course


Watch this course on YouTube at Spring Boot Tutorial | Fee 5 Hours Full Course

Comments