Bird
0
0

What is the role of the @Before annotation inside an aspect class?

easy📝 Conceptual Q2 of 15
Spring Boot - Aspect-Oriented Programming
What is the role of the @Before annotation inside an aspect class?
ADefines advice to run only if a method throws an exception
BDefines advice to run after a matched method executes
CDefines advice to run before a matched method executes
DDefines advice to replace the matched method
Step-by-Step Solution
Solution:
  1. Step 1: Understand advice types

    The @Before annotation marks advice that runs before the target method.
  2. Step 2: Compare with other advice

    @After runs after, @AfterThrowing runs on exceptions, and @Around can replace method execution.
  3. Final Answer:

    Defines advice to run before a matched method executes -> Option C
  4. Quick Check:

    @Before advice = runs before method [OK]
Quick Trick: @Before runs advice before the method executes [OK]
Common Mistakes:
  • Mixing @Before with @After
  • Thinking @Before handles exceptions
  • Confusing @Before with @Around

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes