53.
What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
class A
{
	int a;
   public:
	A(){}
};
 
class B: public A
{
	int b;
    public:
	B(){}
};
 
void func()
{
	B b;
	throw b;
}
 
int main()
{
	try{
		func();
	}
	catch(B b){
		cout<<"Caught B Class\n";
	}
	catch(A a){
		cout<<"Caught A Class\n";
	}
}

54.
Where should we place catch block of the derived class in a try-catch block?

55.
What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
class A
{
	int a;
    public:
	A(){}
};
 
class B: public A
{
	int b;
    public:
	B(){}
};
 
void func1()
{
	B b;
	throw b;
}
 
void func2()
{
	A a;
	throw a;
}
 
int main()
{
	try{
		func1();
	}
	catch(...){
		cout<<"Caught All types of exceptions\n";
	}
	try{
		func2();
	}
	catch(B b){
		cout<<"Caught All types of exceptions\n";
	}
}

57.
What is an exception in C++ program?

59.
By default, what a program does when it detects an exception?

60.
What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
void func(int a, int b)
{
    if(b == 0){
    	throw "This value of b will make the product zero. " 
                 "So please provide positive values.\n";
    }
    else{
    	cout<<"Product of "<<a<<" and  "<<b<<" is: "<<a*b<<endl;
    }
}
 
int main()
{
    try{
    	func(5,0);
    }
    catch(char* e){
    	cout<<e;
    }
}