Question
#include <iostream>
#include <typeinfo>
using namespace std;
class Polymorphic {virtual void Member(){}};
int main ()
{
try
{
Polymorphic * pb = 0;
typeid(*pb);
}
catch (exception& e)
{
cerr << "exception caught: " << e.what() << endl;
}
return 0;
}
a.
exception caught: std::bad_typeid
b.
exception caught: std::bad_alloc
c.
exception caught: std::bad_cast
d.
none of the mentioned
Posted under Object Oriented Programming Using C++
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. What is the output of this program?
Similar Questions
Discover Related MCQs
Q. How to handle error in the destructor?
View solution
Q. What kind of exceptions are available in c++?
View solution
Q. What is meant by exception specification?
View solution
Q. Identify the correct statement about throw(type).
View solution
Q. What will happen when a programs throws any other type of exception other than specified?
View solution
Q. What do you mean by “No exception specification”?
View solution
Q. Which operations don’t throw anything?
View solution
Q. What will happen when an exception is uncaught?
View solution
Q. Which handler is used to handle all types of exception?
View solution
Q. Which operator is used in catch-all handler?
View solution
Q. What function will be called when we have a uncaught exception?
View solution
Q. What will not be called when the terminate() is arised in constructor?
View solution
Q. What will happen when we move try block far away from catch block?
View solution
Q. What will happen if an excpetion that is thrown may causes a whole load of objects to go out of scope?
View solution
Q. What operation can be performed by destructor?
View solution
Q. What is the main purpose of the constructor?
View solution
Q. Why is it expensive to use objects for exception?
View solution
Q. Which alternative can replace the throw statement?
View solution
Q. What are the disadvantages if use return keyword to return error codes?
View solution
Q. What is most suitable for returning the logical errors in the program?
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Object Oriented Programming Using C++? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!