Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumJavaCompletableFuture compositionSingle-choice MCQ

An upstream supplyAsync stage throws, then the chain has .exceptionally(ex -> 42).thenApply(v -> v + 1). What does get() return?

CompletableFuture<Integer> cf = CompletableFuture.<Integer>supplyAsync(() -> { throw new RuntimeException("boom"); }) .exceptionally(ex -> 42) .thenApply(v -> v + 1); System.out.println(cf.get());