J.VI · Java 25 practice question

When a developer calls `ScopedValue.newInstance()` twice to create `SV1` and `SV2`, how are their initial states described?

void main() {
    ScopedValue<String> sv1 = ScopedValue.newInstance();
    ScopedValue<String> sv2 = ScopedValue.newInstance();
    System.out.println(sv1.isBound() + "," + sv2.isBound());
}
Choose one answer
Check answer and explanation

Correct answer: Both are initially unbound for all threads.

Explanation

Each call to `ScopedValue.newInstance()` creates a new `ScopedValue` that is initially unbound for all threads.

Common trap

Neither instance is pre-bound to an empty string or any other value.

Source: Java SE 25 API: ScopedValue.newInstance
Checked against the cited text on 2026-11-27.

Report an error in this question