QuizzesCompletableFuture — Advanced Patterns — Concept Check
intermediate
java

CompletableFuture — Advanced Patterns — Concept Check

Questions on CompletableFuture — Advanced Patterns. Advanced CompletableFuture patterns — custom executors, timeout handling, retry logic, bulkhead isolation, and combining complex async pipelines.

8 minutes 8 questions Pass at 70%
Time Limit
8 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

8 questions on CompletableFuture — Advanced Patterns — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A service using CompletableFuture experiences blocked threads due to slow I/O tasks. What pattern can help mitigate this issue?

    • AReducing the number of async tasks
    • BIncreasing the number of threads in the common pool
    • CUsing ForkJoinPool.commonPool() for all tasks
    • DBulkhead pattern with separate thread pools
  2. 2.You have a service that occasionally fails due to transient network issues. Which approach is best for handling retries?

    • ARetry with exponential backoff using CompletableFuture
    • BRetry with a constant delay
    • CUsing a single retry attempt
    • DImmediate retry without delay
  3. 3.In a fan-out/fan-in pattern, what happens if one of the parallel async calls fails?

    • AThe entire operation fails
    • BThe failed call blocks the entire operation
    • CAll results are discarded
    • DThe failed call returns null, allowing partial results collection
  4. 4.What is the role of orTimeout() in CompletableFuture?

    • AIncreases task priority on timeout
    • BCancels the task immediately
    • CSets a deadline for task completion
    • DRetries the task on timeout
  5. 5.A payment processing service using CompletableFuture is causing high latency. What could be a reason?

    • AUsing virtual threads for email service
    • BSaturating the paymentPool with slow tasks
    • CImplementing exponential backoff
    • DUsing separate thread pools for each service
  6. 6.When using withRetry() with exponential backoff, what is the purpose of jitter?

    • ATo immediately retry after a failure
    • BTo decrease the delay with each retry
    • CTo ensure retries happen at fixed intervals
    • DTo avoid synchronized retries across multiple services
  7. 7.In the bulkhead pattern, what is the effect of using separate thread pools for different services?

    • AIt prevents one service's failure from affecting others
    • BIt eliminates the need for retries
    • CIt reduces the need for async programming
    • DIt increases the overall response time
  8. 8.Why might you use completeOnTimeout() in a CompletableFuture pipeline?

    • ATo retry the task on timeout
    • BTo provide a fallback result if a task exceeds its deadline
    • CTo cancel the task immediately
    • DTo increase task priority on timeout