-
What is the output of this program?
#include <iostream>
using namespace std;
int main()
{
int num = -2;
char *p;
p = new char[50];
try
{
if (num < 0)
{
throw num;
}
if (p == NULL)
{
throw "p is NULL ";
}
}
catch (...)
{
cout << "Exception occurred: exiting"<< endl;
}
return 0;
}
-
- Compilation Error
- Runtime Error
- p is NULL
- Exception occurred: exiting
- None of these
Correct Option: D
catch(…) is used to catch all types of exceptions arising in the program.