CPP

CPP

Grouping of Exceptions has 7 Questions
How many types of exception handling are there in c++?

1
2
3
4
How many runtime error messages associated with exception?

2
4
5
infinite
Which block should be placed after try block?

catch
throw
either catch or throw
none of the mentioned

10
2
Bad Operator
10 / 5 = 2
What is the output of this program?
  1.     #include 
  2.     using namespace std;
  3.     void PrintSequence(int StopNum)
  4.     {
  5.         int Num;
  6.         Num = 1;
  7.         while (true)
  8.         {
  9.             if (Num >= StopNum)
  10.                 throw Num;
  11.             cout << Num << endl;
  12.             Num++;
  13.         }
  14.     }
  15.     int main(void)
  16.     {
  17.         try
  18.         {
  19.             PrintSequence(2);
  20.         }
  21.         catch(int ExNum)
  22.         {
  23.             cout << "exception: " << ExNum << endl;
  24.         }
  25.         return 0;
  26.     }

1
exception: 2
1 exception: 2
none of the mentioned
What is the output of this program?
  1.     #include 
  2.     using namespace std;
  3.     int main()
  4.     {
  5.         int a = 10, b = 20, c = 30;
  6.         float  d;
  7.         try
  8.         {
  9.             if ((a - b) != 0)
  10.             {
  11.                 d = c / (a - b);
  12.                 cout << d;
  13.             }
  14.             else
  15.             {
  16.                 throw(a - b);
  17.             }
  18.         }
  19.         catch (int i)
  20.         {
  21.             cout<<"Answer is infinite "<<i;
  22.         }
  23.     }

10
-3
15
none of the mentioned
What is the output of this program?
  1.     #include 
  2.     using namespace std;
  3.     void test(int x)
  4.     {
  5.         try
  6.         {
  7.             if (x > 0)
  8.                 throw x;
  9.             else
  10.                 throw 'x';
  11.         }
  12.         catch(int x)
  13.         {
  14.             cout<<"integer:"<<x;
  15.         }
  16.         catch(char x)
  17.         {
  18.             cout << "character:" << x;
  19.         }
  20.     }
  21.     int main()
  22.     {
  23.         test(10);
  24.         test(0);
  25.     }

integer:10character:x
integer:10
character:x
none of the mentioned