1.

What is the output of this program?
#include <iostream>
using namespace std;
class ExceptionClass
{
public:
ExceptionClass(int value) : mValue(value)
{
}
int mValue;
};
class DerivedExceptionClass : public ExceptionClass
{
public:
DerivedExceptionClass(int value, int anotherValue) : ExceptionClass(value),mAnotherValue(anotherValue)
{
}
int mValue;
int mAnotherValue;
};
void doSomething()
{
throw DerivedExceptionClass(10,20);
}
int main()
{
try
{
doSomething();
}
catch (DerivedExceptionClass &exception)
{
cout << "Caught Derived Class Exception";
}
catch (ExceptionClass &exception)
{
cout << "Caught Base Class Exception";
}
return 0;
}

A. Caught Base Class Exception
B. Compilation Error
C. Caught Derived Class Exception
D. Runtime Error
E. None of these
Answer» D. Runtime Error


Discussion

No Comment Found

Related MCQs