Skip to content
Sharp

Modern Java · interview question

Which of the following code snippets correctly uses a text block to format a SQL query?

Multiple choiceHardchapter-12-curatedpremiummodern-javatext-blocks
Choose one answer
Answer and explanation

Correct answer

D. String query = """ SELECT * FROM users WHERE name = 'John'; """

Why

The correct usage of a text block for a SQL query ends with triple double quotes ("""). The snippet must start and end with """ and properly contain the SQL statement.

Test yourself on Modern Java

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

Start free test
All Modern Java questions →