Introduction to Compilers MCQs January 8, 2026December 13, 2024 by u930973931_answers 10 min Score: 0 Attempted: 0/10 Subscribe 1. What is the primary purpose of a compiler? (A) To execute programs directly (B) To compile programs for runtime environments (C) To perform memory management (D) To translate high-level programming languages to machine code 2. Which of the following is NOT a type of compiler? (A) Single-pass compiler (B) Multi-pass compiler (C) Machine code compiler (D) Just-in-time compiler 3. What is the main difference between a compiler and an interpreter? (A) A compiler translates code line by line, while an interpreter translates the entire program at once (B) There is no difference (C) A compiler is faster than an interpreter (D) A compiler translates the entire program at once, while an interpreter translates code line by line 4. Which of the following is the first phase of compilation? (A) Semantic analysis (B) Code optimization (C) Lexical analysis (D) Code generation 5. What does a multi-pass compiler do? (A) Translates the entire program in a single pass (B) Analyzes the program in multiple stages to optimize it (C) Runs the program directly on the hardware (D) Only checks for syntax errors 6. Which of the following is true about a Just-in-time (JIT) compiler? (A) It compiles code before execution and stores it in memory (B) It works in a single pass (C) It compiles code at runtime to optimize execution speed (D) It translates source code into machine code without execution 7. What is the primary difference between an assembler and a compiler? (A) An assembler translates high-level language to machine code, while a compiler translates assembly language to machine code (B) A compiler only processes one instruction at a time (C) Both are the same (D) An assembler translates assembly language to machine code, while a compiler translates high-level language to machine code 8. What is a typical output of the compilation process? (A) An interpreted script (B) A debug file (C) A source code file (D) A binary file or executable 9. Which phase of compilation is responsible for checking the syntax of the program? (A) Syntax analysis (B) Semantic analysis (C) Lexical analysis (D) Code generation 10. What is the role of a lexical analyzer in the compilation process? (A) To translate the program into machine code (B) To convert high-level programming language constructs into tokens (C) To check the program’s syntax and semantics (D) To generate intermediate code