MCQ - Exception Handling in C++ Programming
21. Which statement is used to catch all types of exceptions?
A. Catch()
B. Catch(Test t)
C. Catch(...)
D. None of the above
View Answer
Ans : C
Explanation: This catch statement will catch all types of exceptions that arises in the program.
22. How to handle error in the destructor?
A. Throwing
B. Terminate
C. Both throwing & terminate
D. None of the above
View Answer
Ans : B
Explanation: It will not throw an exception from the destructor but it will the process by using terminate() function.
23. What kind of exceptions are available in c++?
A. Handled
B. Unhandled
C. Static
D. Dynamic
View Answer
Ans : B
Explanation: Unhandled exceptions are available in c++
24. Which of the following is true about exception handling in C++?
i) There is a standard exception class like Exception class in Java.
ii) All exceptions are unchecked in C++, i.e., compiler doesn't check if the exceptions are caught or not.
iii) In C++, a function can specify the list of exceptions that it can throw using comma separated list like following.
A. Only i,iii
B. Only i,ii
C. Only ii,iii
D. All of the above
View Answer
Ans : B
Explanation: While during dynamic memory allocation, Your system may not have sufficient resources to handle it, So it is better to use it inside the try block.
25. What is the basic of grouping standard exception classes,in c++?
A. Catch
B. None of these
C. Error
D. Namespace std
View Answer
Ans : D
Explanation: This catch statement will catch all types of exceptions that arises in the program
26. What is a count of standard exception?
A. 9
B. 5
C. 6
D. 7
View Answer
Ans : A
Explanation: It will not throw an exception from the destructor but it will the process by using terminate() function.
27. What should be included in try block in c++ programming language?
A. Static value
B. Dynamic allocation
C. None of the above
D. Const value
View Answer
Ans : B
Explanation: Dynamic allocation should be included in try block in c++ programming language.
28. How many standard exception exist in c++?
A. 9
B. 5
C. 6
D. 7
View Answer
Ans : B
Explanation: 5 many standard exception exist in c++.
29. Catch-all handlers uses which operators in c++?
A. String operators
B. Ternary operators
C. Ellipses operators
D. Unary operators
View Answer
Ans : C
Explanation: Catch-all handlers uses Ellipses operators in c++
30. Uncaught exception will call which function?
A. Terminate
B. Catch
C. None of the above
D. Throw
View Answer
Ans : A
Explanation: Uncaught exception will call Terminate function
31. Which operator in c++ programming language , is used by catch-all handler?
A. Ellipses operator
B. Ternary operator
C. String operator
D. Unary operator
View Answer
Ans : A
Explanation: Ellipses operator in c++ programming language , is used by catch-all handler.
32. How to handle exception in constructor, in c++?
A. We have to return an exception
B. We have to throw an exception
C. Both A and B
D. None of the above
View Answer
Ans : B
Explanation: We have to throw an exception to handle exception in constructor, in c++
33. How many parameter does the throw expression has, in c++?
A. 1
B. 2
C. 3
D. 4
View Answer
Ans : A
Explanation: 1 parameter does the throw expression has, in c++.
Also check :
Discussion