Skip to content
Sharp

Networking · interview question

How would you explain a potential benefit of using CompletableFuture.supplyAsync to fetch data from multiple API endpoints in parallel in an interview?

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

Correct answer

B. It reduces the total time required by leveraging multiple threads.

Why

Using CompletableFuture.supplyAsync allows multiple asynchronous tasks to run in parallel, reducing the total latency by utilizing multiple threads. This is particularly useful when making independent API requests, as it can significantly decrease the overall execution time compared to serial execution.

Test yourself on Networking

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

Start free test
All Networking questions →