Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
using namespace std;
3.
void test(int x)
4.
{
5.
try
6.
{
7.
if (x > 0)
8.
throw x;
9.
else
10.
throw 'x';
11.
}
12.
catch(char)
13.
{
14.
cout
Options:
A .  Catch a integer and that integer is:10
B .  Error
C .  Runtime error
D .  None of the mentioned
Answer: Option C

As the catch is created with a wrong type, So it will
arise a runtime error.
Output:
$ g++ expef.cpp
$ a.out
Testing multiple catches
terminate called after throwing an instance of /int'
:Aborted



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers