Exam 1z0-809 All QuestionsBrowse all questions from this exam
Question 202

Given the code fragment:

Assume that:

The required database driver is configured in the classpath.

The appropriate database is accessible with the dbURL, userName, and passWord exists.

The Employee and Customer tables are available and each table has id column with a few records and the SQL queries are valid.

What is the result of compiling and executing this code fragment?

    Correct Answer: C

    The code attempts to use the same ResultSet object (rs) for two different queries without closing the first one. When the second query is executed, it overwrites the existing ResultSet object. Java allows only one ResultSet per Statement to be open at a time. Without closing the first ResultSet before opening the second one, an exception will be thrown. Therefore, the program will result in an exception being printed.

Discussion
petetsaiOption: B

answer is B , it has "rs = " grabbing customer's results

jduarteOption: C

C The detailed reason is Only one resultSet must be open for statement the code into null pointer exception

iSnoverOption: B

The answer is B. ResultSet overwrites it.

duydnOption: C

C - resource in Try-with-resource is final, cannot re-assign

duydn

sorry, the correct answer is B rs is take data from Customer

WilsonKKerllOption: B

Answer is B.

mevltOption: B

The answer is B. ResultSet overwrites it.