J.IX · Java 25 practice question

In Java 25, what is the return value of `ScopedValue.where(V, 10).call(() -> V.get() + 5)`?

void main() throws Exception {
    ScopedValue<Integer> V = ScopedValue.newInstance();
    int result = ScopedValue.where(V, 10).call(() -> V.get() + 5);
    System.out.println(result);
}
Choose one answer
Check answer and explanation

Correct answer: 15

Explanation

`V` is bound to `10` inside `call`, so `V.get() + 5` evaluates to `15`.

Common trap

Returning `10` or `5` ignores either the bound value or the addition.

Source: JEP 506: Scoped Values — Goals
Checked against the cited text on 2026-11-27.

Report an error in this question