Machine-translated by Google. Questions are authored in English.
Top

Discussion

Exception handling is not meant to handle problems for which case ?

(i) termination of program
(ii) handle return value representing error
(iii) hand return a legal value and leave the program in an illegal state
(iv) call an error handler function

  • A.(i) and (ii)
  • B.(ii) and (iii)
  • C.(iv) only
  • D.(i), (ii) and (iv)

Answer: C

The key is (iv) only, and the source behind it could not be traced.

The four items are the usual ways a program can deal with a run-time error without exceptions: terminate, return an error value, return a legal value and leave the program in an illegal state, or call an error-handler function. Exception handling is introduced as a replacement for those approaches, and the question asks which case it is not meant for. The key picks the call to an error handler function.

The wording is unclear. A search found a similar list of alternatives to exceptions in a C++ textbook but nothing that names (iv) as the one exception handling is not meant for, so the answer rests on the key. Options A, B and D each include (i), (ii) or (iii), which the key treats as cases exceptions do cover.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.