Bird
0
0

Why is ResponseEntity preferred over returning just an object in Spring Boot REST controllers?

hard📝 Conceptual Q10 of 15
Spring Boot - REST Controllers
Why is ResponseEntity preferred over returning just an object in Spring Boot REST controllers?
AIt forces synchronous processing of requests
BIt provides full control over HTTP status, headers, and body
CIt disables HTTP caching by default
DIt automatically serializes objects to XML
Step-by-Step Solution
Solution:
  1. Step 1: Understand ResponseEntity benefits

    ResponseEntity allows setting status, headers, and body explicitly.
  2. Step 2: Compare with returning just object

    Returning only an object limits control to body and default status 200.
  3. Final Answer:

    It provides full control over HTTP status, headers, and body -> Option B
  4. Quick Check:

    Full HTTP control = D [OK]
Quick Trick: ResponseEntity gives full HTTP response control [OK]
Common Mistakes:
  • Thinking it only serializes to XML
  • Assuming it disables caching automatically
  • Believing it affects request processing mode

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes