Bird
0
0

What is wrong with this advice?

medium📝 Debug Q7 of 15
Spring Boot - Aspect-Oriented Programming
What is wrong with this advice?
@AfterReturning(pointcut = "execution(* service.*.getData(..))", returning = "result")
public void advice(String data) {
    System.out.println(data);
}
AThe advice method should have no parameters.
BThe parameter name 'data' does not match the 'returning' attribute 'result'.
CThe pointcut expression is incorrect.
DThe advice method must return a value.
Step-by-Step Solution
Solution:
  1. Step 1: Check parameter name vs returning attribute

    The returning attribute is "result", so the advice method parameter must be named result.
  2. Step 2: Identify mismatch

    The method parameter is named "data", which does not match "result" causing a runtime error.
  3. Final Answer:

    The parameter name 'data' does not match the 'returning' attribute 'result'. -> Option B
  4. Quick Check:

    Parameter name must match returning attribute exactly [OK]
Quick Trick: Parameter name must match returning attribute [OK]
Common Mistakes:
  • Using different parameter name than returning attribute
  • Assuming parameter name can differ
  • Ignoring parameter name case sensitivity

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes