Skip to content
Sharp

SQL for Java Devs · interview question

In JDBC, which method is used to execute a SQL SELECT query and return a ResultSet?

Multiple choiceMediumchapter-8-curatedpremiumsql-for-java-devsrepository-pattern
Choose one answer
Answer and explanation

Correct answer

D. ExecuteQuery

Why

The executeQuery method is used to execute SQL statements that return a ResultSet, typically SELECT statements. The executeUpdate method is used for DML statements like INSERT, UPDATE, or DELETE.

Test yourself on SQL for Java Devs

A free test with instant, explained results. No account needed.

Start free test
All SQL for Java Devs questions →