Bird
0
0

Consider this Spring Boot async method:

medium📝 component behavior Q4 of 15
Spring Boot - Async Processing

Consider this Spring Boot async method:

@Async
public CompletableFuture fetchResult() {
  return CompletableFuture.completedFuture("Success");
}

What does the caller receive when invoking fetchResult()?

AA CompletableFuture immediately completed with "Success"
BThe string "Success" directly
CA null value because the method is async
DAn exception because async methods cannot return values
Step-by-Step Solution
Solution:
  1. Step 1: Understand return type of async method

    The method returns a CompletableFuture<String> which is completed immediately.
  2. Step 2: Caller behavior

    The caller receives the CompletableFuture object, not the raw string.
  3. Final Answer:

    A CompletableFuture immediately completed with "Success" -> Option A
  4. Quick Check:

    Async methods returning CompletableFuture return the future, not direct value [OK]
Quick Trick: Async method returns CompletableFuture, not direct result [OK]
Common Mistakes:
  • Expecting direct return value instead of CompletableFuture
  • Assuming async method returns null
  • Thinking async methods cannot return values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes