Which statement about the finally block in standard C++ exception handling is correct?

Options

  • A. C++ provides a standard finally block like Java.
  • B. C++ does not have a standard finally keyword.
  • C. finally is mandatory after every catch block.
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. C++ does not have a standard finally keyword.

Detailed Explanation

Answer: (B) C++ does not have a standard finally keyword.

Unlike some other programming languages, standard C++ does not provide a finally keyword as part of its built-in exception-handling syntax.

C++ commonly uses techniques such as destructors and RAII to ensure that resources are properly released when control leaves a scope.

The basic C++ exception-handling mechanism uses try, throw and catch.