Intermediate Code Generation MCQs January 8, 2026December 14, 2024 by u930973931_answers 15 min Score: 0 Attempted: 0/15 Subscribe 1. What is the primary purpose of intermediate code generation in a compiler? (A) To translate the source code into an intermediate representation that is independent of the target machine (B) To generate machine code directly (C) To perform lexical analysis (D) To optimize the source code for execution 2. Which of the following is NOT a type of intermediate code representation? (A) Three-address code (B) Assembly code (C) Abstract syntax tree (D) Bytecode 3. What is a primary advantage of using intermediate code during compilation? (A) It makes the compiler faster (B) It simplifies machine code generation by decoupling the target architecture (C) It reduces the size of the source code (D) It helps in performing more complex lexical analysis 4. Which of the following statements is true regarding intermediate code generation? (A) It generates the final machine code directly (B) It generates an intermediate form that can be optimized before final code generation (C) It is only used in interpreting languages, not in compilers (D) It is only used in JIT (Just-in-Time) compilers 5. In which phase of the compiler does the intermediate code generation take place? (A) Lexical analysis (B) Code generation (C) Semantic analysis (D) Syntax analysis 6. Which of the following is an example of an intermediate code representation? (A) Machine code (B) Source code (C) Syntax tree (D) Three-address code 7. What does three-address code consist of? (A) A series of high-level language instructions (B) A list of memory addresses (C) Instructions that use at most three addresses (operands) for each instruction (D) Low-level machine instructions 8. Which of the following is a characteristic of an intermediate code? (A) It is independent of any specific machine architecture (B) It cannot be optimized (C) It must always be in assembly language (D) It is used only for debugging purposes 9. Why is intermediate code useful in a compiler? (A) It speeds up the execution of the program (B) It eliminates the need for syntax checking (C) It helps the programmer write code more efficiently (D) It allows the compiler to perform target-specific optimizations 10. Which of the following is the main advantage of generating intermediate code for optimization purposes? (A) It ensures that the final code will run faster (B) It makes the code platform-independent (C) It allows for machine-specific optimizations (D) It ensures syntax errors are avoided 11. Which of the following is an example of an intermediate code generator in real-world compilers? (A) LLVM IR (B) Assembler (C) Linker (D) Preprocessor 12. In the context of intermediate code generation, what is the purpose of generating a “control flow graph”? (A) To represent the structure of the program’s source code (B) To generate machine-level instructions (C) To check for syntax errors (D) To represent the sequence of statements and conditional branches in a program 13. Which of the following is true about the intermediate code in a compiler? (A) It is the final output of the compilation process (B) It is generated by the syntax analyzer (C) It is always platform-specific (D) It helps decouple optimization from machine code generation 14. What is one benefit of using intermediate code for cross-platform compilation? (A) The compiler generates machine code for each target architecture (B) The code is always executed on a virtual machine (C) The intermediate code can be further translated into machine code for different target platforms (D) The source code becomes platform-independent 15. What is a key feature of an intermediate code like three-address code? (A) It provides a higher level of abstraction from machine code (B) It is easy for humans to understand (C) It uses four or more operands in each instruction (D) It directly translates into machine code