What is meant by exception specification?

A function is limited to throwing only a specified list of exceptions.
A catch can catch all types of exceptions.
A function can throw any type of exceptions.
none of the mentioned
Identify the correct statement about throw(type).

A function can throw any type of exceptions.
A function can throw an exception of certain type only.
A function can't throw any type of exception.
none of the mentioned
What will happen when a programs throws any other type of exception other than specified?

terminate
arise an error
run
none of the mentioned
What is the output of this program?
  1.     #include 
  2.     using namespace std;
  3.     void empty() throw() 
  4.     {
  5.         cout << "In empty()";
  6.     }
  7.     void with_type() throw(int) 
  8.     {
  9.         cout << "Will throw an int";
  10.         throw(1);
  11.     }
  12.     int main() 
  13.     {
  14.         try 
  15.         {
  16.             empty();
  17.             with_type();
  18.         }
  19.         catch (int) 
  20.         {
  21.             cout << "Caught an int";
  22.         }
  23.     }

In empty()
Will throw an int
Caught an int
All of the mentioned
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     #include
  4.     using namespace std;
  5.     int main( )
  6.     {
  7.         try
  8.         {
  9.             string strg1("Test");
  10.             string strg2("ing");
  11.             strg1.append(strg2, 4, 2);
  12.             cout << strg1 << endl;
  13.         }
  14.         catch (exception &e)
  15.         {
  16.             cout << "Caught: " << e.what() << endl;
  17.             cout << "Type: " << typeid(e).name() << endl;
  18.         };
  19.         return 0;
  20.     }

out of range
bad type_id
bad allocation
none of the mentioned
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     using namespace std;
  4.     class Myshape
  5.     {
  6.         public:
  7.         virtual void myvirtualfunc() const {}
  8.     };
  9.     class mytriangle: public Myshape
  10.     {
  11.         public:
  12.         virtual void myvirtualfunc() const
  13.         {   
  14.         };
  15.     };
  16.     int main()
  17.     {
  18.         Myshape Myshape_instance;
  19.         Myshape &ref_Myshape = Myshape_instance;
  20.         try 
  21.         {
  22.             mytriangle &ref_mytriangle = dynamic_cast<mytriangle&>(ref_Myshape);
  23.         }
  24.         catch (bad_cast)
  25.         {
  26.             cout << "Can't do the dynamic_cast lor!!!" << endl;
  27.             cout << "Caught: bad_cast exception. Myshape is not mytriangle.\n";
  28.         }
  29.         return 0;
  30.     }

Can't do the dynamic_cast lor!!!
Caught: bad_cast exception. Myshape is not mytriangle.
both a & b
none of the mentioned
What is the output of this program?
  1.     #include 
  2.     using namespace std;
  3.     int main()
  4.     {
  5.         char* ptr;
  6.         unsigned long int Test = sizeof(size_t(0) / 3);
  7.         cout << Test << endl;
  8.         try
  9.         {
  10.             ptr = new char[size_t(0) / 3];
  11.             delete[ ] ptr;
  12.         }
  13.         catch (bad_alloc &thebadallocation)
  14.         {
  15.             cout << thebadallocation.what() << endl;
  16.         };
  17.         return 0;
  18.     }

4
2
bad_alloc
depends on compiler
What do you mean by "No exception specification"??

It throws nothing
It can throw anything
It can catch anything
none of the mentioned
Which operations don't throw anything?

Operations which are reversible.
Operations which are irreversible.
Operations which are static.
Operations which are dynamic.