Uncaught Exceptions(C++ Programming ) Questions and Answers
Explanation:- Answer: Option C. -> destructor
None.
Explanation:- Answer: Option C. -> terminate
If we have an uncaught exception means, compiler will throw the control of program to
terminate function.
Question 3. What is the output of this program?
1.
#include
2.
using namespace std;
3.
#include
4.
#include
5.
void Funct()
6.
{
7.
cout
Integer exception raised. Funct() was called by terminate(). both a & b none of the mentioned
Explanation:- Answer: Option B. -> Funct() was called by terminate().
As there is no integer in this program, We are printing Funct() was called by terminate(). Output: $ g++ uce4.cpp $ a.out Funct() was called by terminate().
Question 4. What is the output of this program?
1.
#include
2.
#include
3.
#include
4.
using namespace std;
5.
void myterminate ()
6.
{
7.
cerr
terminate handler called Aborted both a & b none of the mentioned
Explanation:- Answer: Option C. -> both a & b
In this program, We are using set_terminate to abort the program. Output: $ g++ uce2.cpp $ a.out terminate handler called Aborted
Question 5. What is the output of this program?
1.
#include
2.
using namespace std;
3.
class Test1
4.
{
5.
};
6.
class Test2 : public Test1 { };
7.
void Funct();
8.
int main()
9.
{
10.
try
11.
{
12.
Funct();
13.
}
14.
catch (const Test1&)
15.
{
16.
cerr
Caught an exception NULL both a & b none of the mentioned
Explanation:- Answer: Option A. -> Caught an exception
In this program, We are arising the exception by using the method in the class. Output: $ g++ uce3.cpp $ a.out Caught a exception