VMware vRealize Automation 8.x (2022) — Question 48
Which statement describes the @AfterReturning advice type? (Choose the best answer.)
Answer options
- A. The advice is invoked only if the method returns successfully but not if it throws an exception.
- B. The @AfterReturning advice allows behavior to be added after a method returns even if it throws an exception.
- C. The advice has complete control over the method invocation; it could even prevent the method from being called at all.
- D. Typically used to prevent any exception, thrown by the advised method, from propagating up the call-stack.
Correct answer: A
Explanation
The correct answer is A because the @AfterReturning advice is specifically designed to execute only after a method has returned successfully, without dealing with exceptions. Option B is incorrect as it misrepresents the behavior of @AfterReturning, while option C describes a characteristic of @Around advice. Option D incorrectly states the purpose of @AfterReturning, which does not prevent exceptions but only runs after successful returns.