Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Multiple Choice Questions
Q1121: Which code generation strategy improves code by considering past and future use of data?
- A: Simple code generation
- B: Optimized code generation
- C: Register allocation
- D: Instruction scheduling
View Answer
B
Q1122: What does the triplet CFG = <V, E, Entry> represent?
- A: A set of variables and functions
- B: A control flow graph with vertices, edges, and program entry
- C: A data structure for memory management
- D: A type of compiler optimization
View Answer
B
Q1123: In a control flow graph, what do vertices (V) represent?
- A: Program variables
- B: Instructions or basic blocks
- C: Memory addresses
- D: Compiler errors
View Answer
B
Q1124: What does the set E represent in a control flow graph?
- A: Vertices
- B: Edges representing control flow between blocks
- C: Source code lines
- D: Syntax trees
View Answer
B
Q1125: The Entry in CFG is:
- A: A set of exit points
- B: A unique program entry point
- C: A list of variables
- D: A pointer to memory
View Answer
B
Q1126: Which of the following best defines a basic block?
- A: A sequence of instructions with multiple entries and exits
- B: A sequence of consecutive statements with single entry and single exit
- C: A single statement in a program
- D: A conditional statement
View Answer
B
Q1127: Which of these is NOT a variant of basic blocks?
- A: Single entry/multiple exit
- B: Multiple entry/single exit
- C: Multiple entry/multiple exit
- D: Single entry/single exit
View Answer
C
Q1128: How are basic blocks generated from intermediate code?
- A: By partitioning the code into blocks based on leaders
- B: By sorting variables alphabetically
- C: By removing all goto statements
- D: By merging functions
View Answer
A
Q1129: What qualifies a statement as a leader in partitioning basic blocks?
- A: The first statement
- B: A target of any goto
- C: A statement immediately following a goto statement
- D: All of the above
View Answer
D
Q1130: In three-address code, what does an unconditional goto instruction do in the CFG?
- A: Creates no edges
- B: Creates a single edge to another or same block
- C: Creates multiple edges
- D: Ends the program
View Answer
B