AllInfoHub Logo

AllInfoHub – MCQ Practice

Compiler Design – Multiple Choice Questions (MCQs)

  1. 1. What is a compiler?

    • A. A program that executes source code
    • B. A program that translates source code into object code
    • C. A program that links object code files
    • D. A program that debugs executable code
  2. 2. What is the role of the lexical analyzer (scanner)?

    • A. To check the grammatical structure of the source code
    • B. To verify the meaning of the source code
    • C. To generate intermediate code
    • D. To break the source code into tokens
  3. 3. What is a token?

    • A. A sequence of characters with a collective meaning
    • B. A single character in the source code
    • C. A line of source code
    • D. An error message from the compiler
  4. 4. What is the role of the syntax analyzer (parser)?

    • A. To break the source code into tokens
    • B. To check the grammatical structure of the source code
    • C. To verify the meaning of the source code
    • D. To generate intermediate code
  5. 5. What is a parse tree?

    • A. A hierarchical representation of the syntactic structure of the source code
    • B. A linear sequence of tokens
    • C. A table of symbols used in the program
    • D. The generated object code
  6. 6. What is the role of the semantic analyzer?

    • A. To break the source code into tokens
    • B. To check the grammatical structure
    • C. To verify the meaning and logical correctness of the source code
    • D. To generate machine code
  7. 7. What is type checking in semantic analysis?

    • A. Verifying that the operands of an operator are of compatible types
    • B. Checking for syntax errors
    • C. Optimizing the code for better performance
    • D. Allocating memory for variables
  8. 8. What is intermediate code?

    • A. A representation of the source code that is between the high-level source code and the low-level machine code
    • B. The original source code
    • C. The final machine code
    • D. The symbol table
  9. 9. Which of the following is a common form of intermediate code?

    • A. Three-address code
    • B. Assembly language
    • C. Machine code
    • D. Bytecode
  10. 10. What is the role of the intermediate code generator?

    • A. To perform lexical analysis
    • B. To perform syntax analysis
    • C. To perform semantic analysis
    • D. To translate the source code into an intermediate representation
  11. 11. What is code optimization?

    • A. The process of improving the intermediate or machine code to make it more efficient
    • B. The process of finding errors in the source code
    • C. The process of translating source code to object code
    • D. The process of linking object code files
  12. 12. What are the two main types of code optimization?

    • A. Machine-dependent and machine-independent
    • B. Lexical and syntax
    • C. Static and dynamic
    • D. Local and global