Skip to content
Sharp

Concurrency basics · interview question

Which CompletableFuture method should be used to execute a task asynchronously in a non-blocking manner?

Multiple choiceMediumchapter-15-curatedpremiumconcurrencycompletablefuture
Choose one answer
Answer and explanation

Correct answer

D. .supplyAsync()

Why

.supplyAsync() is used to execute a Supplier asynchronously, providing a CompletableFuture for the result. It allows non-blocking execution, making it suitable for tasks with return values.

Test yourself on Concurrency basics

A free test with instant, explained results. No account needed.

Start free test
All Concurrency basics questions →