Skip to content
Sharp

SQL for Java Devs · interview question

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

Multiple choiceEasychapter-8-curatedpremiumsql-for-java-devspreparedstatements
Choose one answer
Answer and explanation

Correct answer

B. Prevention of SQL injection attacks.

Why

PreparedStatements allow developers to safely bind parameters, preventing SQL injection attacks. This is because the SQL command structure is precompiled and parameters are treated as data, not executable code.

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 →