AllInfoHub Logo

AllInfoHub – MCQ Practice

Compiler Design – Multiple Choice Questions (MCQs)

  1. 13. What is constant folding?

    • A. Evaluating constant expressions at compile time
    • B. Replacing variables with their values
    • C. Eliminating redundant code
    • D. Moving code outside loops
  2. 14. What is dead code elimination?

    • A. Removing code that will never be executed
    • B. Replacing complex code with simpler code
    • C. Rearranging the order of instructions
    • D. Allocating registers for variables
  3. 15. What is loop unrolling?

    • A. Expanding a loop by replicating its body multiple times
    • B. Converting loops into recursive functions
    • C. Optimizing the loop condition
    • D. Moving loop-invariant code outside the loop
  4. 16. What is common subexpression elimination?

    • A. Identifying and replacing multiple occurrences of the same expression with a single computation
    • B. Reordering expressions for better performance
    • C. Simplifying complex expressions
    • D. Inserting checks for potential errors
  5. 17. What is the role of the code generator?

    • A. To perform lexical analysis
    • B. To perform syntax analysis
    • C. To perform semantic analysis
    • D. To translate the intermediate code into the target machine code
  6. 18. What is a symbol table?

    • A. A data structure that stores information about the identifiers used in the source code
    • B. A table of operators used in the language
    • C. A representation of the syntax of the language
    • D. A table of error messages
  7. 19. What is lexical analysis?

    • A. The first phase of a compiler that breaks the source code into tokens
    • B. The second phase that checks the syntax
    • C. The third phase that checks the meaning
    • D. The final phase that generates machine code
  8. 20. What is parsing?

    • A. The process of analyzing the sequence of tokens to determine its grammatical structure
    • B. The process of generating tokens
    • C. The process of checking the meaning of the code
    • D. The process of optimizing the code
  9. 21. What is a top-down parsing technique?

    • A. A parsing technique that starts with the root of the parse tree and tries to derive the input string
    • B. A parsing technique that starts with the input string and tries to build the parse tree from the leaves up
    • C. A parsing technique that uses a table to guide the parsing process
    • D. A parsing technique that uses recursion extensively
  10. 22. Which of the following is a top-down parsing algorithm?

    • A. LL(1)
    • B. LR(0)
    • C. SLR(1)
    • D. LALR(1)
  11. 23. What is a bottom-up parsing technique?

    • A. A parsing technique that starts with the root of the parse tree
    • B. A parsing technique that starts with the input string and tries to build the parse tree from the leaves up
    • C. A parsing technique that uses recursion
    • D. A parsing technique that predicts the next token
  12. 24. Which of the following is a bottom-up parsing algorithm?

    • A. LL(1)
    • B. LR(0)
    • C. Recursive Descent
    • D. Predictive Parsing