Bird
0
0

Given the pointcut expression execution(public * com.example.repo.*Repository.find*(..)), which methods will it match?

medium📝 component behavior Q13 of 15
Spring Boot - Aspect-Oriented Programming
Given the pointcut expression execution(public * com.example.repo.*Repository.find*(..)), which methods will it match?
AAll methods named 'find' in any class in com.example.repo
BAll public methods starting with 'find' in any class ending with 'Repository' in package com.example.repo
CAll public methods in any class in com.example.repo
DOnly methods named exactly 'find' in any class ending with 'Repository'
Step-by-Step Solution
Solution:
  1. Step 1: Break down the expression

    public * means any public return type, com.example.repo.*Repository matches classes ending with 'Repository' in the package, and find*(..) matches methods starting with 'find' with any parameters.
  2. Step 2: Match options to expression meaning

    All public methods starting with 'find' in any class ending with 'Repository' in package com.example.repo correctly describes all public methods starting with 'find' in classes ending with 'Repository' in the package. Others are either too broad or too narrow.
  3. Final Answer:

    All public methods starting with 'find' in any class ending with 'Repository' in package com.example.repo -> Option B
  4. Quick Check:

    execution(public * com.example.repo.*Repository.find*(..)) = All public methods starting with 'find' in any class ending with 'Repository' in package com.example.repo [OK]
Quick Trick: Look for wildcards * and method name patterns carefully [OK]
Common Mistakes:
  • Ignoring method name prefix 'find*'
  • Confusing class name pattern *Repository
  • Missing public modifier effect

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes