J.VI · Java 25 practice question

Which static factory method on `java.lang.ScopedValue` creates a new `ScopedValue` instance in Java 25?

Choose one answer
Check answer and explanation

Correct answer: `ScopedValue.newInstance()`

Explanation

`ScopedValue.newInstance()` is the public static factory method that creates a new, initially unbound `ScopedValue`.

Common trap

`withInitial()` belongs to `ThreadLocal`, not `ScopedValue`. `createBound()` does not exist on `ScopedValue`.

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

Report an error in this question