How many levels are there in exception safety?
2
3
1
4
View Answer
Correct Answer: B — 3
Explanation:
No explanation is available for this question yet.
Browse topic-based Object Oriented Programming Using C++ practice sets.
24 practice sets · Page 2 of 2
How many levels are there in exception safety?
2
3
1
4
Correct Answer: B — 3
Explanation:
No explanation is available for this question yet.
What is the use of RAII in c++ programing?
Improve the exception safety
Exit from the block
None of the mentioned
Terminate the program
Correct Answer: A — Improve the exception safety
Explanation:
No explanation is available for this question yet.
What is the output of this program?
#include <stdexcept>
#include <limits>
#include <iostream>
using namespace std;
void MyFunc(char c)
{
if (c < numeric_limits<char>::max())
return invalid_argument;
}
int main()
{
try
{
MyFunc(256);
}
catch(invalid_argument& e)
{
cerr << e.what() << endl;
return -1;
}
return 0;
}
Error
Invalid argument
256
None of the mentioned
Correct Answer: A — Error
Explanation:
No explanation is available for this question yet.
What is the output of this program?
#include <iostream>
using namespace std;
void Division(const double a, const double b);
int main()
{
double op1=0, op2=10;
try
{
Division(op1, op2);
}
catch (const char* Str)
{
cout << "\nBad Operator: " << Str;
}
return 0;
}
void Division(const double a, const double b)
{
double res;
if (b == 0)
throw "Division by zero not allowed";
res = a / b;
cout << res;
}
0
None of the mentioned
10
Bad operator
Correct Answer: A — 0
Explanation:
No explanation is available for this question yet.