Skip to content
Sharp

Networking · interview question

When asynchronously calling multiple APIs with CompletableFuture, how can you ensure all tasks are completed?

Multiple choiceHardchapter-11-curatedpremiumnetworkingtimeouts-and-retries
Choose one answer
Answer and explanation

Correct answer

B. Use CompletableFuture.allOf()

Why

CompletableFuture.allOf() is used to wait until all provided CompletableFutures complete. This method is ideal when you have multiple asynchronous tasks and want to proceed only when all tasks have finished.

Test yourself on Networking

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

Start free test
All Networking questions →