What happens if you call the method close() on a ResultSet object?

  1. O (a) the method close() does not exist for a ResultSet. Only Connections can be closed.

  2. O (b) the database and JDBC resources are released

  3. O (c) you will get a SQLException, because only Statement objects can close ResultSets

  4. O (d) the ResultSet, together with the Statement which created it and the Connection from


Correct Option: B
Explanation:

To answer this question, the user needs to have a basic understanding of Java Database Connectivity (JDBC) and ResultSet objects.

Option A is incorrect. The close() method does exist for ResultSet objects.

Option B is correct. If you call the close() method on a ResultSet object, the resources associated with the ResultSet will be released and returned to the database. This includes any database and JDBC resources that were used to create the ResultSet.

Option C is incorrect. The close() method can be called on a ResultSet object, but not on a Statement object. It is the Statement object that creates the ResultSet.

Option D is incorrect. While the ResultSet is associated with the Statement and Connection objects that created it, calling the close() method on the ResultSet will only release the resources associated with the ResultSet itself, not the Statement or Connection objects.

Therefore, the answer is: B. O (b) the database and JDBC resources are released.

Find more quizzes: