LearnFrenzy
Sign in Take a free test

Concurrency and Executors · Concurrency and Executors MCQ · Question 9

thenApply versus thenCompose Answer, explanation & discussion

  • MCQ
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 9 Back to Exercise

When should thenCompose be used instead of thenApply?

  • A Never
  • B When the next step itself returns a CompletableFuture, to avoid a nested CompletableFuture<CompletableFuture<T>> Correct
  • C When combining two independent futures
  • D When handling errors
Correct Answer: Option B

thenCompose is like flatMap; thenCombine joins two independent futures.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links