What will be the outcome if you try to execute a DML (Data Manipulation Language) operation using executeQuery() method?

  • The DML operation will execute successfully, and the result set will be returned.
  • A SQLException will be thrown, as executeQuery() is meant for querying data, not for DML operations.
  • The DML operation will execute, but no result set will be returned.
  • An UnsupportedOperationException will be thrown, indicating that executeQuery() cannot be used for DML operations.
When you try to execute a DML operation (such as INSERT, UPDATE, DELETE) using the executeQuery() method, option b is correct. It will throw a SQLException because executeQuery() is meant for querying data and returns a ResultSet, which is not applicable to DML operations. Options a and c are incorrect because they suggest that the DML operation can proceed, which is not the case. Option d is also incorrect; it does not represent the actual behavior of executeQuery().
Add your answer
Loading...

Leave a comment

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