NSCT – Exception & Error Handling MCQs 20 min Score: 0 Attempted: 0/20 Subscribe 1. What is an exception in programming? (A) A variable (B) A type of loop (C) A function (D) An unexpected event or error during program executionShow All Answers 2. What is error handling? (A) A way to create loops (B) The process of managing and responding to errors or exceptions (C) A method for input/output (D) A data storage technique 3. Which of the following is an example of a runtime error? (A) Dividing a number by zero (B) Syntax mistake in the code (C) Missing a semicolon (D) Typing a variable name incorrectly 4. Which of the following is an example of a compile-time error? (A) Syntax error (B) Division by zero (C) File not found (D) Null pointer exception 5. What is an exception handler? (A) A function that prints output (B) A type of loop (C) A data type (D) A block of code that executes when an exception occurs 6. Which keyword is commonly used to handle exceptions in many programming languages? (A) All of the above (B) catch (C) throw (D) try 7. What does the try block do? (A) Terminates the program (B) Executes code after exception occurs (C) Contains code that might raise an exception (D) Declares a variable 8. What does the catch block do? (A) Ends the program (B) Executes code normally (C) Declares a function (D) Handles the exception raised in the try block 9. What is the purpose of the finally block? (A) To execute code regardless of whether an exception occurred or not (B) To declare variables (C) To create a loop (D) To terminate the program 10. Which of the following is used to raise an exception manually? (A) catch (B) try (C) throw / raise (D) finally 11. Which type of error can be handled using exception handling? (A) Compilation errors (B) Syntax errors (C) Runtime errors (D) None of the above 12. Which of the following is an example of a logical error? (A) File not found (B) Dividing by zero (C) Misspelling a keyword (D) Using the wrong formula in calculations 13. What happens if an exception is not handled? (A) The program loops infinitely (B) The program runs normally (C) The program terminates abruptly (D) The program creates a variable 14. Which of the following statements is true about exceptions? (A) Exceptions occur at runtime (B) Exceptions occur at compile time (C) Exceptions always terminate the program (D) Exceptions cannot be handled 15. Which type of exception occurs when a program tries to access a file that does not exist? (A) IndexOutOfBoundsException (B) SyntaxError (C) NullPointerException (D) FileNotFoundException 16. Which exception occurs when trying to access an invalid index in a collection? (A) SyntaxError (B) FileNotFoundException (C) IndexOutOfBoundsException (D) DivideByZeroException 17. Which exception occurs when attempting to use a null reference? (A) SyntaxError (B) DivideByZeroException (C) NullPointerException (D) FileNotFoundException 18. Why is exception handling important? (A) To create loops (B) To make programs more robust and prevent crashes (C) To store variables (D) To define classes 19. Which of the following is used to clean up resources, like closing files, after exception handling? (A) finally block (B) catch block (C) try block (D) throw statement 20. What is the main goal of exception and error handling in programming? (A) To define functions (B) To create loops (C) To store values in arrays (D) To detect, manage, and recover from errors safely