Skip to content
Sharp

SQL for Java Devs · interview question

Why do teams use PreparedStatements over Statements in JDBC in production code?

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

Correct answer

A. PreparedStatements prevent SQL injection attacks.

Why

PreparedStatements help prevent SQL injection attacks by separating SQL logic from data values. This is achieved by precompiling SQL statements and using parameter placeholders.

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 →