Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Multiple Choice Questions

Q761: What does the set I0 = closure({[S → •E, $]}) contain initially?
  • A: Only [S → •E, $]
  • B: Items for S and E productions
  • C: Only terminal items
  • D: Only lookahead symbols
View Answer
B

Q762: The initial set of LR(1) items I0 contains which of the following items?
  • A: [S → •E, $]
  • B: [E → •E+(E), $/+]
  • C: [E → •int, $/+]
  • D: All of the above
View Answer
D

Q763: In the LR(1) item [E → •int, $/+], why does the closure procedure add no new items?
  • A: The dot is at the end
  • B: The dot is followed by terminal int
  • C: The dot is followed by non-terminal
  • D: Epsilon production
View Answer
B

Q764: If [A → β•Cδ, a] ∈ s, what does closure add for the production C → γ?
  • A: Items with dot at the end
  • B: Items with dot before γ and lookahead from FIRST(δa)
  • C: Items without dot
  • D: None
View Answer
B

Q765: The lookahead symbols added in closure for a production C → γ include all terminals in which set?
  • A: FIRST(δ)
  • B: FIRST(a)
  • C: FIRST(δa)
  • D: FOLLOW(C)
View Answer
C

Q766: The function goto(s, y) returns what?
  • A: The set of items with dot before y
  • B: Closure of all items with dot after y
  • C: Closure of all items with dot moved past y
  • D: Items with dot at the end
View Answer
C

Q767: What does the goto procedure do in LR(1) parser construction?
  • A: It computes parser states after recognizing symbol y
  • B: It deletes items with dot before y
  • C: It adds new productions
  • D: It simplifies grammar
View Answer
A

Q768: In the goto procedure, for each item [X → α•yβ, b] ∈ s, what is added to m?
  • A: [X → α y•β, b]
  • B: [X → α•yβ, b]
  • C: [X → α yβ•, b]
  • D: [X → α β•y, b]
View Answer
A

Q769: LR(1) items are used as states in what kind of automaton?
  • A: Finite Automaton
  • B: Non-deterministic Finite Automaton
  • C: Deterministic Finite Automaton
  • D: Both A and C
View Answer
D

Q770: The LR(1) parser’s finite automaton starts as which type before subset construction?
  • A: NFA
  • B: DFA
  • C: Moore Machine
  • D: Mealy Machine
View Answer
A

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now