Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Multiple Choice Questions

Q1131: If there is no goto at the end of a block, where does control pass?
  • A: To the previous block
  • B: To the first statement of the next block
  • C: To a random block
  • D: To the program exit
View Answer
B

Q1132: What is the role of the 'partition' algorithm in CFG generation?
  • A: To execute the program faster
  • B: To group three-address statements into basic blocks
  • C: To delete unreachable code
  • D: To optimize memory usage
View Answer
B

Q1133: In the dot product example, how many basic blocks are formed?
  • A: One
  • B: Two
  • C: Three
  • D: Four
View Answer
B

Q1134: In the dot product code, which statement type indicates a leader?
  • A: The first statement
  • B: The target of a conditional goto
  • C: The statement following a goto
  • D: All of the above
View Answer
D

Q1135: In CFG, what does an edge from one basic block to another represent?
  • A: Variable assignment
  • B: Control flow
  • C: Function call
  • D: Memory allocation
View Answer
B

Q1136: Which of the following is true about the quicksort algorithm example?
  • A: It uses recursion
  • B: It is iterative only
  • C: It uses only unconditional gotos
  • D: It does not use basic blocks
View Answer
A

Q1137: What is the first step in computing live/next use information?
  • A: Removing all variables
  • B: Initializing live set with all non-temporary variables
  • C: Generating basic blocks
  • D: Emitting machine code
View Answer
B

Q1138: In liveness analysis, a variable is live if:
  • A: It is defined in the program
  • B: It has a next use
  • C: It is used in the current statement
  • D: It is a temporary variable
View Answer
B

Q1139: What is the purpose of computing live variables at each statement?
  • A: To optimize memory usage
  • B: To generate faster code
  • C: To know which variables' values need to be preserved
  • D: To detect errors in code
View Answer
C

Q1140: For the statement "x = y + z", what variables get added to the live set?
  • A: y and z
  • B: x only
  • C: x and y
  • D: z only
View Answer
A

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now