J.VI · Java 25 practice question
A developer needs a concurrency type that can both be completed explicitly with a result and chain dependent actions that trigger upon completion. Which pair of interfaces implemented by CompletableFuture<T> provides these capabilities?
Check answer and explanation
Correct answer: Future<T> and CompletionStage<T>
Explanation
CompletableFuture<T> implements Future<T> and CompletionStage<T>, combining explicit completion of a future value with composable dependent functions and actions.
Common trap
Choosing Future<T> and AutoCloseable is tempting because ExecutorService implements AutoCloseable, but CompletableFuture does not implement AutoCloseable. Choosing Runnable and CompletionStage<T> is tempting because FutureTask implements Runnable, whereas CompletableFuture implements Future<T> rather than Runnable.
Source: Java SE 25 API: CompletableFuture
Checked against the cited text on 2026-11-25.