Multiple choice technology architecture

Which type of Statement can execute parameterized queries?

  1. PreparedStatement

  2. ParameterizedStatement

  3. ParameterizedStatement and CallableStatement

  4. All kinds of Statements (i.e. which implement a sub interface of Statement)

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

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

The correct answer is:

A. PreparedStatement

Explanation:

PreparedStatement is a subinterface of the Statement interface in JDBC. It allows the execution of parameterized queries, which are SQL statements that contain parameters (placeholders) that can be set with specific values at runtime. Parameterized queries are useful for preventing SQL injection attacks and improving query performance by allowing the database to cache query execution plans.

Option B, ParameterizedStatement, is not a valid interface in JDBC.

Option C, ParameterizedStatement and CallableStatement, is incorrect because CallableStatement is a subinterface of PreparedStatement, not Statement.

Option D, All kinds of Statements, is incorrect because not all types of statements in JDBC can execute parameterized queries. Only PreparedStatement can execute parameterized queries.

Therefore, the correct answer is A. PreparedStatement.