Error Handling MCQs December 19, 2025December 14, 2024 by u930973931_answers 30 min Score: 0 Attempted: 0/30 Subscribe 1. What is the main goal of error handling in compilers? (A) To detect, report, and recover from errors gracefully (B) To ignore errors (C) To slow down compilation (D) To optimize code 2. Which type of errors can a compiler detect? (A) Runtime errors only (B) Lexical, syntax, and semantic errors (C) Hardware errors (D) Network errors 3. What is panic-mode error recovery? (A) Ignoring errors completely (B) Re-running the compiler (C) Skipping input tokens until a designated synchronizing token is found (D) Stopping compilation immediately 4. Which of the following is an advantage of panic-mode recovery? (A) It guarantees no errors in output (B) Simple and prevents cascading errors (C) Provides precise error correction (D) Minimizes compilation time drastically 5. What is phrase-level recovery? (A) Deleting the entire program (B) Performing local corrections to replace or insert tokens to continue parsing (C) Restarting the compiler (D) Ignoring all semantic errors 6. Which error recovery method is more precise but complex? (A) Panic-mode (B) Ignoring errors (C) Phrase-level recovery (D) Logging errors only 7. What is the main disadvantage of panic-mode recovery? (A) It is too complex (B) Slows down compilation (C) Cannot detect lexical errors (D) May skip multiple statements, losing context 8. What is an error recovery set? (A) A set of tokens that helps the parser resume after an error (B) A set of all semantic errors (C) A collection of runtime errors (D) A list of warning messages 9. In which phase of compilation are most error recovery techniques applied? (A) Lexical analysis (B) Syntax analysis (parsing) (C) Code optimization (D) Code generation 10. What is the purpose of an error message in a compiler? (A) To confuse the programmer (B) To slow down compilation (C) To indicate the location and nature of the error (D) To optimize code 11. Which of the following is NOT a common strategy for compiler error handling? (A) Panic-mode recovery (B) Global correction of all errors at once (C) Phrase-level recovery (D) Error productions 12. What are error productions in a parser? (A) Grammar rules added specifically to detect common errors (B) Tokens ignored by the parser (C) Instructions for code generation (D) Reserved keywords 13. Which type of errors do error productions mainly handle? (A) Rare runtime errors (B) Frequently occurring syntactic errors (C) Lexical errors only (D) Semantic errors only 14. Which error recovery technique is best for real-time systems requiring fast compilation? (A) Phrase-level recovery (B) Error productions (C) Panic-mode recovery (D) Backtracking recovery 15. What is backtracking recovery? (A) Compiler ignores the program (B) Parser attempts alternative derivations to correct errors (C) Error messages are suppressed (D) Program is executed despite errors 16. What is a semantic error recovery method? (A) Inserting missing tokens (B) Adjusting types or values to maintain program correctness (C) Skipping entire statements (D) Ignoring errors 17. Which of the following is a characteristic of good error handling? (A) Reporting errors with accurate location (B) All of the above (C) Minimizing cascading errors (D) Allowing compilation to continue if possible 18. What is a common problem if error recovery is not implemented? (A) The compiler runs faster (B) Cascading errors and misleading messages (C) The program executes perfectly (D) All errors are automatically corrected 19. Which technique modifies the grammar to include common mistakes? (A) Error productions (B) Phrase-level recovery (C) Panic-mode (D) Semantic checks 20. What is a “synchronizing token” in panic-mode recovery? (A) The first token of the program (B) A token representing a semantic error (C) A token where parsing can safely resume after an error (D) A keyword ignored by the compiler 21. Why is error handling important in educational compilers? (A) To optimize code (B) To teach students how to debug (C) To execute the program faster (D) To ignore incorrect programs 22. Which of the following is an example of phrase-level recovery? (A) Skipping all tokens until a semicolon (B) Ignoring type mismatches (C) Logging errors without recovery (D) Replacing a missing semicolon to continue parsing 23. How does the compiler typically indicate multiple errors in a program? (A) Uses error recovery to continue parsing and reports all detected errors (B) Stops at the first error (C) Ignores the rest of the program (D) Corrects errors automatically 24. What type of error handling is most suitable for beginner-friendly compilers? (A) Phrase-level recovery with clear messages (B) Panic-mode (C) No error handling (D) Backtracking recovery only 25. Which of the following is a runtime error, not a compile-time error? (A) Division by zero detected at runtime (B) Missing semicolon (C) Misspelled keyword (D) Using undeclared variable 26. What is the term for errors that occur during code execution rather than compilation? (A) Lexical errors (B) Syntax errors (C) Runtime errors (D) Semantic errors 27. In panic-mode recovery, what happens if no synchronizing token is found? (A) Compilation stops (B) The compiler guesses corrections (C) Compiler skips to the next statement (D) Semantic errors are reported instead 28. Which error recovery method tries to make minimal changes to continue parsing? (A) Panic-mode (B) Error productions (C) Phrase-level recovery (D) Backtracking recovery 29. Which compiler phase is least concerned with error recovery? (A) Code generation (B) Syntax analysis (C) Semantic analysis (D) Lexical analysis 30. What is a common output of an error-handling mechanism in a compiler? (A) Optimized code (B) Execution of program (C) List of detected errors with line numbers and suggestions (D) Ignoring all errors silently