Examveda

What is the use of <exception> header

A. Contains the standard exception files

B. Contains the standard library files

C. It is used to arise an exception in the program

D. Reduce the memory size

Answer: Option A

Solution (By Examveda Team)

The <exception> header in C++ is specifically designed to handle errors and unusual situations that occur during the execution of a program.
It defines a hierarchy of standard exception classes, such as std::exception, std::bad_alloc, std::runtime_error, and others.
These classes are used to represent different types of errors and provide a way to report and handle them gracefully.
Option B is incorrect because <exception> doesn't contain all standard library files.
Option C is partially correct, as exceptions can be raised, but <exception> primarily *defines* the exception classes, not directly raise them (though you can throw instances of these classes).
Option D is incorrect because <exception> has nothing to do with reducing memory size. Its purpose is for error handling.

Join The Discussion

Comments (1)

  1. Gopal Ambore
    Gopal Ambore:
    10 months ago

    The answer to question should be B) contains the standard library files

Related Questions on Standard Template Library (STL) in C plus plus