Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Multiple Choice Questions

Q431: What does the non-terminal "WithElse" in the rewritten grammar help resolve?
  • A: Operator precedence
  • B: Assignment ambiguity
  • C: If-then-else ambiguity
  • D: Function calls
View Answer
C

Q432: The leftmost derivation applies production rules to the __________ non-terminal first.
  • A: Rightmost
  • B: Leftmost
  • C: Any
  • D: None
View Answer
B

Q433: In the example grammar, what is the first step to parse x - 2 * y?
  • A: Expr โ†’ Expr โ€“ Term
  • B: Expr โ†’ Term
  • C: Expr โ†’ Factor
  • D: Expr โ†’ Term * Factor
View Answer
A

Q434: Which grammar rule type uses the form A โ†’ a with no context restrictions?
  • A: Context-sensitive
  • B: Context-free
  • C: Regular
  • D: Unambiguous
View Answer
B

Q435: Fill in the blank: In bottom-up parsing, parsing grows from the __________ to the __________.
  • A: Leaves, root
  • B: Root, leaves
  • C: Left, right
  • D: Right, left
View Answer
A

Q436: What is the main disadvantage of ambiguous grammars?
  • A: Difficulty parsing multiple expressions
  • B: Multiple parse trees cause ambiguity
  • C: No parse trees generated
  • D: No terminals found
View Answer
B

Q437: Which parsing technique uses backtracking when it picks wrong production rules?
  • A: Top-down
  • B: Bottom-up
  • C: Leftmost
  • D: Rightmost
View Answer
A

Q438: In the classic if-then-else ambiguity, which statement causes the ambiguity?
  • A: Multiple else statements
  • B: Multiple then statements
  • C: Nesting of if without else
  • D: Nesting of else without if
View Answer
C

Q439: What is the effect of creating a non-terminal for each level of precedence?
  • A: It removes ambiguity
  • B: It simplifies the grammar
  • C: It encodes expected operator precedence
  • D: It removes terminals
View Answer
C

Q440: What does the term "backtrack-free grammar" imply?
  • A: Grammar without recursion
  • B: Grammar without ambiguity
  • C: Grammar without need for backtracking
  • D: Grammar without terminals
View Answer
C

Test Your Knowledge

Take a timed quiz on Compiler Construction

๐Ÿš€ Start Quiz Now