Skip to content
Sharp

Modern Java · interview question

What main advantage do text blocks provide when embedding JSON or SQL in Java code?

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

Correct answer

A. They allow multiline strings without special escaping.

Why

Text blocks allow for multiline strings without special escaping, which improves readability and maintainability when embedding JSON or SQL. This helps avoid issues with string concatenation and escaping.

Test yourself on Modern Java

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

Start free test
All Modern Java questions →