Bird
0
0

Which HTTP response behavior is automatically handled by a class annotated with @RestController?

easy📝 Conceptual Q2 of 15
Spring Boot - REST Controllers
Which HTTP response behavior is automatically handled by a class annotated with @RestController?
AIt returns view names for templates
BIt redirects to another URL
CIt throws exceptions for all methods
DIt serializes return objects to JSON or XML
Step-by-Step Solution
Solution:
  1. Step 1: Recall @RestController response behavior

    Methods in a @RestController return data directly, not views.
  2. Step 2: Understand serialization

    Spring Boot automatically converts returned objects to JSON or XML for HTTP responses.
  3. Final Answer:

    It serializes return objects to JSON or XML -> Option D
  4. Quick Check:

    @RestController returns serialized data [OK]
Quick Trick: RestController returns data, not views [OK]
Common Mistakes:
  • Thinking it returns view templates
  • Assuming it redirects automatically
  • Believing it throws exceptions always

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes