Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Multiple Choice Questions

Q561: The parser reads the token 'id' as input. Which rule is applied?
  • A: F → id
  • B: T → id
  • C: F → (E)
  • D: E → T
View Answer
B

Q562: What does the FIRST(X) set represent in grammar analysis?
  • A: All terminal symbols in the grammar
  • B: All non-terminal symbols that can derive epsilon
  • C: The set of terminals that begin strings derivable from X
  • D: The set of terminals following X in derivations
View Answer
C

Q563: Which of the following is TRUE about LL(1) parsing?
  • A: It constructs the parse tree from leaves to root
  • B: It requires backtracking
  • C: It expands the rightmost non-terminal
  • D: It always expands the leftmost non-terminal
View Answer
D

Q564: In LL(1) table construction, when is a production A → a valid?
  • A: When FIRST(a) contains the current token
  • B: When FOLLOW(A) contains a terminal symbol
  • C: When A is a terminal symbol
  • D: When a is not nullable
View Answer
A

Q565: If ε ∈ FIRST(A), what does it imply?
  • A: A is a terminal
  • B: A is not used in derivation
  • C: A can derive an empty string
  • D: A can only derive a terminal
View Answer
C

Q566: What does FOLLOW(A) represent?
  • A: All terminals that can follow A in any derivation
  • B: All terminals that A can start with
  • C: All non-terminals that follow A
  • D: The set of terminals at the beginning of A
View Answer
A

Q567: What is the purpose of FIRST and FOLLOW sets in LL(1) parsing?
  • A: To check syntax errors
  • B: To determine operator precedence
  • C: To construct predictive parsing tables
  • D: To compute symbol frequency
View Answer
C

Q568: In LL(1) parsing, what happens if M[X,a] = error?
  • A: The parser crashes
  • B: The parser uses backtracking
  • C: The parser calls an error recovery routine
  • D: The parser restarts from beginning
View Answer
C

Q569: A grammar is suitable for LL(1) parsing if:
  • A: It contains left recursion
  • B: It is left-factored and non-left-recursive
  • C: It contains right recursion only
  • D: It allows ambiguity
View Answer
B

Q570: What is the initial content of the parsing stack in LL(1) parsing?
  • A: Just $
  • B: Start symbol followed by $
  • C: Start symbol only
  • D: Input string followed by $
View Answer
B

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now