nerdexam
Broadcom-VMware

2V0-72.22PSE · Question #97

Which type of advice can be used to stop an exception propagating up the stack, and to return an error value instead?

The correct answer is D. @Around. @Around is correct because it wraps the entire method execution, giving you full control - you can catch exceptions in a try/catch block, prevent them from propagating, and return a fallback value instead. The other options lack this power: @AfterThrowing runs after an…

Core Spring

Question

Which type of advice can be used to stop an exception propagating up the stack, and to return an error value instead?

Options

  • A@AfterThrowing
  • B@After
  • C@Before
  • D@Around

How the community answered

(27 responses)
  • A
    4% (1)
  • B
    7% (2)
  • C
    11% (3)
  • D
    78% (21)

Explanation

@Around is correct because it wraps the entire method execution, giving you full control - you can catch exceptions in a try/catch block, prevent them from propagating, and return a fallback value instead. The other options lack this power: @AfterThrowing runs after an exception is already thrown and cannot suppress it or substitute a return value. @After is a finally-style advice that always runs after the method but cannot intercept or swallow exceptions. @Before runs before method execution and has no access to exceptions at all.

Memory tip: Think of @Around as a bodyguard - it's the only advice that can intercept, block, and redirect what happens, because it physically surrounds the join point with ProceedingJoinPoint.proceed(). If you can't call proceed(), you can't stop or replace anything.

Topics

#Spring AOP#@Around advice#Exception handling#Method interception

Community Discussion

No community discussion yet for this question.

Full 2V0-72.22PSE Practice