Bird
0
0

What is the main purpose of the @Service annotation in a Spring Boot application?

easy📝 Conceptual Q2 of 15
Spring Boot - Spring Annotations
What is the main purpose of the @Service annotation in a Spring Boot application?
ATo indicate a class contains business logic
BTo mark a class as a web controller
CTo define a database repository
DTo create a generic Spring bean
Step-by-Step Solution
Solution:
  1. Step 1: Identify the role of @Service

    @Service is used to mark classes that hold business logic or service layer code.
  2. Step 2: Compare with other stereotypes

    @Controller handles web requests, @Repository handles data access, and @Component is generic.
  3. Final Answer:

    To indicate a class contains business logic -> Option A
  4. Quick Check:

    Business logic = @Service [OK]
Quick Trick: Use @Service for business logic to separate concerns cleanly [OK]
Common Mistakes:
  • Using @Service for controllers
  • Confusing @Service with @Repository
  • Not using any stereotype annotation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes