Skip to content
Sharp

Modern Java · interview question

Given the following Java text block for a SQL query, what will be the result of the indentation?

Multiple choiceMediumchapter-12-curatedpremiummodern-javatext-blocks
java
String query = """
    SELECT * FROM products
    WHERE price > 100
    ORDER BY name;
""";
Choose one answer
Answer and explanation

Correct answer

B. The indentation will be trimmed to match the least-indented line.

Why

The Java compiler trims leading whitespace up to the level of the least-indented line in a text block. This helps maintain alignment and readability without altering the intended structure.

Test yourself on Modern Java

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

Start free test
All Modern Java questions →