Exception Handling
- What kind of exceptions are available in c++?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
unhandled
- What is meant by exception specification?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
C++ provides a mechanism to ensure that a given function is limited to throwing only a specified list of exceptions. It is called as exception specification.
- Identify the correct statement about throw(type).
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
A function can throw an exception of certain type only
- What will happen when a programs throws any other type of exception other than specified?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
arise an error
- What is the output of this program?
#include <iostream>
using namespace std;
void Example() throw()
{
cout << "In empty()" << endl;
}
void WithTypeFunction() throw(int)
{
cout << "Will throw an int" << endl;
throw(1);
}
int main()
{
try
{
Example();
WithTypeFunction();
}
catch (int)
{
cout << "Caught an int" << endl;
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
It will print all three because we are calling all functions in the main().