Skip to content
Sharp

Networking · interview question

How does CompletableFuture.supplyAsync differ from runAsync?

Multiple choiceMediumchapter-11-curatedpremiumnetworkingasynchronous-http
Choose one answer
Answer and explanation

Correct answer

C. SupplyAsync returns a result, while runAsync does not.

Why

CompletableFuture.supplyAsync is used when you want to perform a computation that returns a result, whereas runAsync is used when no result is expected, such as running a side-effect operation.

Test yourself on Networking

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

Start free test
All Networking questions →