J.VI · Java 25 practice question

What is the initial binding state of a `ScopedValue` returned by `ScopedValue.newInstance()`?

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

Correct answer: It is initially unbound for all threads.

Explanation

`ScopedValue.newInstance()` creates a `ScopedValue` that starts out unbound for all threads, so `isBound()` returns `false`.

Common trap

A newly created `ScopedValue` is not bound to `null` or any default string; it is completely unbound until explicitly bound with `ScopedValue.where`.

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

Report an error in this question