Test Series - spring

Test Number 7/20

Q: Which advice combines all advices into one?
A. @Before
B. @After
C. @AfterThrowing
D. None of the mentioned
Solution: It gains full control of a join point, so you can combine all the actions of the preceding advices into one single advice. You can even control when, and whether, to proceed with the original join point execution.
Q: An advice can access the current join point information by declaring an argument of type org.aspectj.lang.AdvicePoint in the advice method signature.
A. True
B. False
C. 1
D. 0
Solution: An advice can access the current join point information by declaring an argument of type org.aspectj.lang.JoinPoint in the advice method signature.
Q: Which interface is implemented to specify precedence of aspects?
A. Ordered
B. ApplicationAspect
C. AspectPointcut
D. None of the mentioned
Solution: The precedence of aspects can be specified either by implementing the Ordered interface.
Q: Alternative annotative way to specify precedence of aspects?
A. @Order
B. @Aspect
C. @PointCut
D. None of the mentioned
Solution: The precedence of aspects can be specified either by implementing the Ordered interface or @Order Annotation.
Q: Method which returns the highest priority of aspect’s join point?
A. getHighestPriority
B. getOrder
C. getHighOrder
D. getPriority
Solution: The lower value returned by the getOrder() method represents higher priority.
Q: Which instantiation model is supported by AspectJ?
A. perthis
B. pertarget
C. none of the mentioned
D. all of the mentioned
Solution: Spring supports AspectJ perthis and pertarget instantiation models.
Q: Which instantiation model is supported by AspectJ?
A. perthis
B. pertarget
C. none of the mentioned
D. all of the mentioned
Solution: percflow, percflowbelow, and pertypewithin are not currently supported.
Q: Which tag in XML is used to declare @Before advice’s method?
A. aop:before
B. aop:after
C. aop:afterthrow
D. None of the mentioned
Solution: Before advice runs before a matched method execution. It is declared inside an aop:aspect using the aop:before element.
Q: Which tag in XML is used to declare @Before advice’s method?
A. aop:before
B. aop:after-returning
C. aop:afterthrow
D. None of the mentioned
Solution: After returning advice runs when a matched method execution completes normally. It is declared inside an aop:aspect in the same way as before advice.
Q: What will be the output of the code snippet?

    import org.aspectj.lang.annotation.Aspect;
    import org.aspectj.lang.annotation.AfterThrowing;
 
    @Aspect
    public class AfterThrowingExample 
    {
 
	  @AfterThrowing(
	    pointcut="com.xyz.myapp.SystemArchitecture.dataAccessOperation()",
	    throwing="ex")
	  public void doRecoveryActions(DataAccessException e)
          {
		throw new IllegalArgumentException();
	    // ...
	  }
 
    }
A. Runtime Error
B. IllegalArgumentException
C. BeanCreation Exception
D. None of the mentioned
Solution: The throwing keyword in pointcut annotation doesn’t matches with the method’s parameter exception.

You Have Score    /10