Bird
0
0

In Spring Boot, what two annotations does @RestController effectively combine?

easy📝 Conceptual Q1 of 15
Spring Boot - REST Controllers
In Spring Boot, what two annotations does @RestController effectively combine?
A<code>@Component</code> and <code>@Entity</code>
B<code>@Service</code> and <code>@Repository</code>
C<code>@Controller</code> and <code>@ResponseBody</code>
D<code>@ControllerAdvice</code> and <code>@ResponseStatus</code>
Step-by-Step Solution
Solution:
  1. Step 1: Understand @RestController

    The @RestController annotation is a convenience annotation that combines two annotations.
  2. Step 2: Identify the combined annotations

    It combines @Controller, which marks the class as a Spring MVC controller, and @ResponseBody, which indicates that the return value of methods should be bound to the web response body.
  3. Final Answer:

    @Controller and @ResponseBody -> Option C
  4. Quick Check:

    Check official Spring documentation for @RestController [OK]
Quick Trick: Combines @Controller and @ResponseBody annotations [OK]
Common Mistakes:
  • Confusing @RestController with @Service or @Repository
  • Thinking it includes @Component or @Entity
  • Assuming it combines @ControllerAdvice or @ResponseStatus

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes