C++ | Exception Handling | Question 6

filter_none

edit
close

play_arrow

link
brightness_4
code

#include <iostream>
using namespace std;
  
int main()
{
    try
    {
       throw 10;
    }
    catch (...)
    {
        cout << "default exception\n";
    }
    catch (int param)
    {
        cout << "int exception\n";
    }
  
    return 0;
}

chevron_right


(A) default exception
(B) int exception
(C) Compiler Error


Answer: (C)

Explanation: It is compiler error to put catch all block before any other catch. The catch(…) must be the last catch block.

Quiz of this Question



My Personal Notes arrow_drop_up