Skip to content
Sharp

Authentication · interview question

When preventing SQL injection attacks in Java, why is using 'PreparedStatement' preferred over plain 'Statement'?

Multiple choiceHardchapter-17-curatedpremiumauthenticationplaintext-passwords
Choose one answer
Answer and explanation

Correct answer

C. PreparedStatement automatically escapes SQL syntax.

Why

PreparedStatement automatically handles parameterized queries, which prevents SQL injection by ensuring that user input is treated as data, not executable SQL code.

Test yourself on Authentication

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

Start free test
All Authentication questions →