Question
When should a Java developer choose ExecutorService, Future, and CompletableFuture deliberately?
- Choose ExecutorService, Future, and CompletableFuture mainly when you want to postpone validation and fix problems manually later.
- Use executors for bounded task execution and CompletableFuture when asynchronous orchestration should remain explicit in the code.
- Choose ExecutorService, Future, and CompletableFuture whenever you want the code to look more advanced, even if the design gets less clear.
- Choose ExecutorService, Future, and CompletableFuture only to avoid modeling domain rules explicitly in Java code.
Hint
Think about the production scenario where the choice genuinely improves the code.
Answer and rationale
Correct answer: B. Use executors for bounded task execution and CompletableFuture when asynchronous orchestration should remain explicit in the code.
Use executors for bounded task execution and CompletableFuture when asynchronous orchestration should remain explicit in the code. Interviewers often ask this to see whether you can connect the concept to real design decisions.
Track: Java