Exception Handling – MCQs July 22, 2025 by u930973931_answers 30 Score: 0 Attempted: 0/30 Subscribe 1. : What is the purpose of exception handling in C++? (A) To reduce the size of the program (B) To increase the speed of program execution (C) To handle runtime errors (D) To avoid syntax errors 2. : Which keyword is used to catch exceptions in C++? (A) catch (B) try (C) throw (D) error 3. : Which keyword is used to throw an exception? (A) raise (B) catch (C) throw (D) error 4. : Which block must be used to enclose code that may throw an exception? (A) error (B) try (C) catch (D) raise 5. : What happens if an exception is not caught in C++? (A) The program executes normally (B) The compiler shows a syntax error (C) The program crashes (D) The program throws a warning 6. : Which function is automatically called when no catch block handles an exception? (A) abort() (B) unexpected() (C) terminate() (D) exit() 7. : Which type of error is best handled using exceptions? (A) Compilation errors (B) Logical errors (C) Syntax errors (D) Runtime errors 8. : Can multiple catch blocks be used with one try block? (A) Yes (B) No (C) Only in Java (D) Only for integer exceptions 9. : What is the correct order of catch blocks? (A) Specific to general (B) General to specific (C) Any order (D) Catch blocks cannot be ordered 10. : What does the ellipsis (…) in a catch block mean? (A) Catches all exceptions (B) Catches integer exceptions (C) Catches syntax errors (D) Is not allowed in C++ 11. : What is the purpose of the try block? (A) To declare a variable (B) To perform file handling (C) To test a block of code for errors (D) To handle syntax errors 12. : What does the throw keyword do? (A) Ignores the error (B) Converts the error (C) Transfers control to catch block (D) Stops the program 13. : Which of the following is a standard exception class in C++? (A) syntax_error (B) divide_by_zero (C) runtime_error (D) input_error 14. : Which header file includes standard exception classes? (A) iostream (B) cstdlib (C) exception (D) string 15. : Can user-defined types be thrown as exceptions? (A) Yes (B) No (C) Only integers (D) Only strings 16. : What is rethrowing an exception? (A) Handling and stopping the exception (B) Catching and throwing it again (C) Ignoring the exception (D) Catching all exceptions 17. : Which exception is thrown when a new operator fails to allocate memory? (A) bad_exception (B) memory_error (C) bad_alloc (D) null_pointer 18. : What is the base class for all standard exceptions in C++? (A) base_exception (B) exception (C) std_exception (D) runtime_error 19. : Can a constructor throw an exception? (A) Yes (B) No (C) Only destructors can (D) Only member functions can 20. : Is it possible to throw primitive data types as exceptions? (A) Yes (B) No (C) Only in C (D) Only in Java 21. : What is the main benefit of exception handling? (A) Makes code slower (B) Improves code readability (C) Separates error handling from regular code (D) Hides logic errors 22. : How many catch blocks can a single try block have? (A) Only one (B) Unlimited (C) Two (D) Maximum three 23. : Which of the following can be caught using a catch block? (A) Compilation errors (B) Runtime exceptions (C) Syntax errors (D) All of the above 24. : What happens when throw is used without an operand inside a catch block? (A) Throws a new exception (B) Re-throws the caught exception (C) Terminates the program (D) Causes a syntax error 25. : What type of exceptions does the standard exception class handle? (A) User-defined only (B) Only logic errors (C) Built-in and derived exceptions (D) None 26. : Which exception class is used for invalid arguments? (A) bad_alloc (B) invalid_argument (C) runtime_error (D) logic_error 27. : Can destructors throw exceptions in C++? (A) Yes, freely (B) No, it’s unsafe (C) Only for standard classes (D) Only in Java 28. : What is noexcept used for in C++? (A) To handle multiple exceptions (B) To declare a function does not throw (C) To catch exceptions (D) To throw exceptions 29. : Which keyword can be used to catch any type of exception? (A) default (B) general (C) … (ellipsis) (D) base 30. : What will happen if you throw an exception inside a noexcept function? (A) Exception is caught (B) Program continues (C) Program terminates (D) Error is ignored