Bird
0
0

Consider this advice:

medium📝 component behavior Q5 of 15
Spring Boot - Aspect-Oriented Programming
Consider this advice:
@After("execution(* service.*.process(..))")
public void afterProcess() {
    System.out.println("Process finished");
}

What happens if process() throws an exception?
AThe message "Process finished" is printed.
BNo message is printed because of the exception.
CA runtime error occurs in advice.
DThe advice runs before the method throws exception.
Step-by-Step Solution
Solution:
  1. Step 1: Understand @After advice behavior

    @After advice runs after method finishes, regardless of success or exception.
  2. Step 2: Effect on output

    Even if process() throws, the advice prints "Process finished".
  3. Final Answer:

    The message "Process finished" is printed. -> Option A
  4. Quick Check:

    @After runs always after method [OK]
Quick Trick: Runs after method ends, even on exceptions [OK]
Common Mistakes:
  • Thinking advice skips on exceptions
  • Confusing with @AfterReturning
  • Assuming advice runs before exception

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes