C++ | Exception Handling | Question 5
#include <iostream> using namespace std; int main() { try { throw 'a'; } catch (int param) { cout << "int exception\n"; } catch (...) { cout << "default exception\n"; } cout << "After Exception"; return 0; } |
chevron_right
filter_none
(A)
default exception After Exception
(B)
int exception After Exception
(C)
int exception
(D)
default exception
Answer: (A)
Explanation: The block catch(…) is used for catch all, when a data type of a thrown exception doesn’t match with any other catch block, the code inside catch(…) is executed.
Note that the implicit type conversion doesn’t happen when exceptions are caught. The character ‘a’ is not automatically converted to int.
Quiz of this Question
Recommended Posts:
- C++ | Exception Handling | Question 11
- C++ | Exception Handling | Question 12
- C++ | Exception Handling | Question 1
- C++ | Exception Handling | Question 2
- C++ | Exception Handling | Question 3
- C++ | Exception Handling | Question 4
- C++ | Exception Handling | Question 10
- C++ | Exception Handling | Question 9
- C++ | Exception Handling | Question 8
- C++ | Exception Handling | Question 7
- C++ | Exception Handling | Question 6
- Java | Exception Handling | Question 1
- Java | Exception Handling | Question 2
- Java | Exception Handling | Question 3
- Java | Exception Handling | Question 4



