Skip to content
Sharp

Spring Security · interview question

Why is it important to use prepared statements in Java when dealing with SQL queries?

Multiple choiceMediumchapter-17-curatedpremiumspring-securityspring-security-filter-chain
Choose one answer
Answer and explanation

Correct answer

A. To prevent SQL injection attacks.

Why

Prepared statements prevent SQL injection by ensuring that user input is treated as data, not executable code. This is crucial for maintaining database security.

Test yourself on Spring Security

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

Start free test
All Spring Security questions →