Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Chapter: 13
Q461:
The symbol ε in grammar rules represents ________.
A. an empty string
B. a terminal
C. a non-terminal
D. a look-ahead symbol
Correct Answer: A
Chapter: 13
Q462:
Which is NOT part of the top-down parsing algorithm?
A. Backtracking on mismatch
B. Constructing root node
C. Building children
D. Evaluating semantic actions
Correct Answer: D
Chapter: 13
Q463:
When a node labeled A is expanded, the parser selects a production with ________ on its left-hand side.
A. A
B. any symbol
C. terminal
D. token
Correct Answer: A
Chapter: 13
Q464:
The example "x – 2 * y" demonstrates issues with ________.
A. left recursion
B. right recursion
C. operator precedence
D. ambiguity
Correct Answer: C
Chapter: 13
Q465:
Removing left recursion preserves the original grammar's ________.
A. left associativity
B. right associativity
C. ambiguity
D. precedence
Correct Answer: A
Chapter: 13
Q466:
In predictive parsing, the amount of look-ahead needed is generally ________.
A. unbounded
B. fixed to one
C. sometimes zero
D. none
Correct Answer: A
Chapter: 13
Q467:
In the grammar A → b A' and A' → a A' | ε, A' is called a ________.
A. auxiliary non-terminal
B. terminal
C. production
D. rule lexer
Correct Answer: A
Chapter: 13
Q468:
The FOLLOW set in parsing is the set of terminals that can appear ________ a given non-terminal.
A. immediately after
B. before
C. in the middle
D. of a string
Correct Answer: A
Chapter: 14
Q469:
The LL(1) property requires that FIRST(a) ∩ FIRST(b) for productions A → a and A → b must be ________.
A. non-empty
B. empty
C. partially overlapping
D. undefined
Correct Answer: B
Chapter: 14
Q470:
In LL(k) parsing, the 'k' stands for the number of ________.
A. look-ahead tokens
B. left-most derivations
C. right-most derivations
D. grammar rules
Correct Answer: A
Chapter: 14
Q471:
If a grammar has ε-productions, to satisfy LL(1) property we must ensure FIRST(b) is disjoint from ________.
A. FIRST(a)
B. FOLLOW(a)
C. FIRST+(a)
D. FOLLOW+(a)
Correct Answer: B
Chapter: 14
Q472:
FOLLOW(a) is defined as the set of terminals that can legally appear ________ a in the grammar.
A. before
B. after
C. inside
D. none of these
Correct Answer: B
Chapter: 14
Q473:
The set FIRST+(a) is defined as FIRST(a) ∪ FOLLOW(a) only if ________ is in FIRST(a).
A. ε
B. $
C. EOF
D. non-terminal
Correct Answer: A
Chapter: 14
Q474:
A grammar is LL(1) if for all productions A → a and A → b, FIRST+(a) ∩ FIRST+(b) is ________.
A. empty
B. full
C. partial
D. undefined
Correct Answer: A
Chapter: 14
Q475:
Predictive parsers are also known as ________ parsers because they predict the correct production.
A. top-down
B. bottom-up
C. shift-reduce
D. recursive
Correct Answer: A
Chapter: 14
Q476:
Which parsing method is a kind of predictive parser?
A. Recursive descent
B. Bottom-up
C. Shift-reduce
D. LR parser
Correct Answer: A
Chapter: 14
Q477:
In the code snippet for LL(1) parsing, if token ∈ FIRST(b1), the parser ________.
A. chooses b1
B. produces error
C. ignores token
D. looks ahead
Correct Answer: B
Chapter: 14
Q478:
A recursive descent parser builds the parse tree in a ________ direction.
A. top-down
B. bottom-up
C. left-to-right
D. right-to-left
Correct Answer: A
Chapter: 14
Q479:
In the provided grammar, expr' can be replaced by ε or expressions involving ________.
A. + or -
B. * or /
C. id or number
D. ( or )
Correct Answer: A
Chapter: 14
Q480:
The grammar symbol 'e' used in the content represents ________.
A. epsilon (empty string)
B. expression
C. terminal
D. non-terminal
Correct Answer: A

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now