Aspectj Support And Scripting(Engineering > Computer Science And Engineering > Spring > Aop ) Questions and Answers

Question 1. How to inject Spring bean into domain objcts
  1.    AOP
  2.    XML
  3.    AspectJ
  4.    Java Based
Explanation:-
Answer: Option A. -> AOP


To inject a Spring bean into domain objects created outside Spring, you need the help of AOP.



Question 2. Special compiler used during weaving
  1.    jvm
  2.    gcc
  3.    ajc
  4.    none of the mentioned
Explanation:-
Answer: Option C. -> ajc


AspectJ compile-time weaving is done through a special AspectJ compiler called ajc.



Question 3. Which advice is executed only when joint point returns or throws an exception?
  1.    @Before
  2.    @After
  3.    @AfterReturning
  4.    @AfterThrowing
Explanation:-
Answer: Option C. -> @AfterReturning


If you would like to perform logging only when a join point returns, you should replace the after advice with an after returning advice.



Question 4. Which of the following is advice supported by Aspect Annotation?
  1.    @Before
  2.    @After
  3.    @AfterReturning
  4.    All of the mentioned
Explanation:-
Answer: Option D. -> All of the mentioned


AspectJ supports five types of advice annotations: @Before, @After, @AfterReturning, @AfterThrowing, and @Around.



Question 5. Lightweight java scripting language executing java fragments
  1.    JRuby
  2.    Groovy
  3.    BeanShell
  4.    All of the mentioned
Explanation:-
Answer: Option C. -> BeanShell


BeanShell is a lightweight Java scripting language that can dynamically execute Java code fragments while supporting scripting features like those of other scripting languages.



Question 6. Is the following pointcut expression correct?execution(* ArithmeticCalculator.*(..))
  1.    Yes
  2.    No
  3.    If every target class is in same package
  4.    Depends where target class is located
Explanation:-
Answer: Option C. -> If every target class is in same package


You can omit the package name if the target class or interface is located in the same package as this aspect.



Question 7. Dynamic-language-backed bean with some configurations
  1.    Refreshable bean
  2.    Beanshell
  3.    Scripting Beans
  4.    Inline Script
Explanation:-
Answer: Option A. -> Refreshable bean





Question 8. XML element to specify the property values for scripting bean
  1.    lang:property
  2.    bean:property
  3.    script:property
  4.    None of the mentioned
Explanation:-
Answer: Option A. -> lang:property


You can specify the property values for a scripting bean in the lang:property elements.



Question 9. Annotation used to declare an introduction
  1.    Before
  2.    After
  3.    @DeclareParents
  4.    None of the mentioned
Explanation:-
Answer: Option C. -> @DeclareParents


In this aspect, you can declare an introduction by annotating an arbitrary field with the @DeclareParents annotation.