Test Series - spring

Test Number 8/20

Q: Annotation used to refer poincuts?
A. @Pointcut
B. @PointcutExecution
C. @PointcutBefore
D. None of the mentioned
Solution: In an AspectJ aspect, a pointcut can be declared as a simple method with the @Pointcut annotation.
Q: PointCut definitions can’t be reused again
A. True
B. False
C. 1
D. 0
Solution: Like many other AOP implementations, AspectJ also allows you to define a pointcut independently to be reused in multiple advices.
Q: Language used to set various kinds of join points
A. AspectJ pointcut language
B. Java pointcut language
C. XML pointcut language
D. None of the mentioned
Solution: The AspectJ pointcut language is a powerful expression language that can match various kinds of join points.
Q: Is the following pointcut expression correct?
execution(* ArithmeticCalculator.*(..))
A. Yes
B. No
C. If every target class is in same package
D. Depends where target class is located
Solution: You can omit the package name if the target class or interface is located in the same package as this aspect.
Q: Which of the following pattern is used to match bean name?
A. bean(*Calculator)
B. bean(Calculator)
C. bean(com.appress.spring.Calculator)
D. None of the mentioned
Solution: The following pointcut expression matches beans whose name ends with Calculator.
Q: Expressions which returns Parameters of pointcuts?
A. target
B. args
C. none of the mentioned
D. all of the mentioned
Solution: The expressions target() and args() capture the target object and argument values of the current join point and expose them as pointcut parameters.
Q: Are logical operators valid in pointcut expressions?
A. Yes
B. No
C. .
D. 0
Solution: In AspectJ, pointcut expressions can be combined with the operators && (and), || (or), and ! (not).
Q: Method which checks if all target classes are matched
A. matches()
B. pair()
C. matchTargetClass()
D. none of the mentioned
Solution: If the matches() method always returns true, all target classes will be matched.
Q: Pointcuts can be composed using:-
A. org.springframework.aop.support.Pointcuts class
B. composablePointcut class
C. all of the mentioned
D. none of the mentioned
Solution: Using the static methods in the org.springframework.aop.support.Pointcuts class, or using the ComposablePointcut class in the same package.
Q: Pointcut used to parse an AspectJ pointcut expression string
A. org.springframework.aop.aspectj.AspectJExpressionPointcut
B. org.springframework.aop.aspectj.AspectJExpressionPointcutString
C. org.springframework.aop.aspectj.AspectJExpressionString
D. org.springframework.aop.aspectj.AspectJPointcuttoString
Solution: Since 2.0, the most important type of pointcut used by Spring is org.springframework.aop.aspectj.AspectJExpressionPointcut. This is a pointcut that uses an AspectJ supplied library to parse an AspectJ pointcut expression string.

You Have Score    /10