What change should you make to apply good coding practices to this fragment?

Given the code fragment: What change should you make to apply good coding practices to
this fragment?

Given the code fragment: What change should you make to apply good coding practices to
this fragment?

A.
Add nested try-with-resources statements for the statement and ResultSet declarations.

B.
Add the statement and ResultSet declarations to the try-with-resources statement.

C.
Add a finally clause after the catch clause.

D.
Rethrow SQLException.



Leave a Reply 3

Your email address will not be published. Required fields are marked *


bob

bob

Please explain why the answer C is supposed to be correct (marked as good answer) rather than the B.

Babak

Babak

correct answer is B