Questions: Exception Handling Implementation

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

What is the primary advantage of table-driven exception handling over the setjmp/longjmp approach?

ATable-driven handling is simpler for the compiler to implement correctly
BTable-driven handling adds no overhead to code that does not throw — the exception table is only consulted when an exception actually occurs
CTable-driven handling allows exceptions to be caught across multiple stack frames simultaneously
DTable-driven handling eliminates the need to run destructors and finally blocks during unwinding
Question 2 Multiple Choice

During stack unwinding after an exception is thrown, what happens when the runtime examines a stack frame that does not contain a matching catch handler?

AExecution returns immediately to the frame's caller without running any cleanup
BThe runtime runs any registered cleanup code (destructors, finally blocks) for that frame, then continues unwinding to the caller
CThe runtime terminates the program immediately since no matching handler was found
DThe runtime suspends unwinding and searches through all loaded libraries for a matching handler
Question 3 True / False

Table-driven exception handling executes additional instructions on most function entry and return to prepare for potential exceptions.

TTrue
FFalse
Question 4 True / False

The compiler must emit exception tables that account for every possible throw point within a function, not just the explicit throw statements.

TTrue
FFalse
Question 5 Short Answer

Explain why table-driven exception handling is called 'zero-cost' and what tradeoff this design involves compared to setjmp/longjmp.

Think about your answer, then reveal below.