Skip to content
Sharp

SQL for Java Devs · interview question

How does a PreparedStatement mitigate the risk of SQL injection?

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

Correct answer

A. By using placeholders that separate code from data

Why

PreparedStatements use placeholders for input data, which are bound to specific data values at runtime. This separation between SQL logic and input data prevents malicious inputs from altering the SQL command structure.

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 →