Skip to content
Sharp

Engineering Interviews · interview question

In the context of SQL injection, which code snippet is most vulnerable?

Multiple choiceMediumchapter-20-curatedpremiumengineering-interviewscode-review-spotting-bugs
Choose one answer
Answer and explanation

Correct answer

B. String query = "SELECT * FROM users WHERE id = " + userId;

Why

Using string concatenation to build SQL queries is highly vulnerable to SQL injection attacks. Prepared statements or parameterized queries should be used instead.

Test yourself on Engineering Interviews

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

Start free test
All Engineering Interviews questions →