Skip to content
Sharp

Authentication · interview question

Why are prepared statements recommended for database interactions in Java?

Multiple choiceMediumchapter-17-curatedpremiumauthenticationsalting-and-bcrypt
Choose one answer
Answer and explanation

Correct answer

A. They prevent SQL injection attacks.

Why

Prepared statements separate SQL code from data, preventing attackers from injecting malicious SQL through user input. This separation ensures that user input is treated strictly as data, not executable code.

Test yourself on Authentication

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

Start free test
All Authentication questions →