Bird
0
0

Which expression is correct?

hard📝 Application Q15 of 15
Spring Boot - Aspect-Oriented Programming
You want to create a pointcut expression that matches all methods in any class within com.app.service and its subpackages, but only methods that have exactly two parameters of any type. Which expression is correct?
Aexecution(* com.app.service..*.*(*, *))
Bexecution(* com.app.service.*.*(..))
Cexecution(* com.app.service..*.*(.., ..))
Dexecution(* com.app.service..*.*(*))
Step-by-Step Solution
Solution:
  1. Step 1: Understand package and subpackage matching

    com.app.service..* matches classes in the package and all subpackages.
  2. Step 2: Match method parameters exactly

    (* , *) means exactly two parameters of any type. (..) means any number of parameters, so it's incorrect here.
  3. Step 3: Analyze options

    execution(* com.app.service..*.*(*, *)) correctly matches all classes in package and subpackages with exactly two parameters. Others either match any number of parameters or wrong parameter counts.
  4. Final Answer:

    execution(* com.app.service..*.*(*, *)) -> Option A
  5. Quick Check:

    Use (*, *) for exactly two parameters [OK]
Quick Trick: Use (*, *) to match exactly two parameters [OK]
Common Mistakes:
  • Using (..) to match exact parameter count
  • Confusing single * with .. for subpackages
  • Missing commas between parameters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes