Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Chapter: 16
Q541:
The production rule for F includes which of the following?
A. F → id
B. F → + E'
C. F → id * F
D. F → e
Correct Answer: A
Chapter: 16
Q542:
In the AST, which operator is applied first in the expression 2 + 4 * 6?
A. +
B. *
C. /
D. =
Correct Answer: B
Chapter: 16
Q543:
Predictive parsing avoids recursion by using ________.
A. stack trace
B. input buffer
C. parsing history
D. token tree
Correct Answer: A
Chapter: 16
Q544:
Which function initiates the parsing process for an expression?
A. Term::isPresent()
B. Expr::isPresent()
C. Factor::isPresent()
D. Eprime::isPresent()
Correct Answer: B
Chapter: 16
Q545:
The input string id+id*id$ ends with which character to signal parsing end?
A. *
B. id
C. +
D. $
Correct Answer: D
Chapter: 16
Q546:
Tprime::isPresent() returns true only when it encounters which operator?
A. +
B. *
C. /
D. * or /
Correct Answer: D
Chapter: 16
Q547:
Eprime handles operations related to which mathematical functions?
A. Addition and Subtraction
B. Multiplication and Division
C. Parentheses
D. Exponentiation
Correct Answer: A
Chapter: 16
Q548:
The call to s->advance() in parsing code is used to
A. Skip whitespaces
B. Move to next token
C. Print token
D. Build tree
Correct Answer: B
Chapter: 16
Q549:
The predictive parsing table has rows as ________ and columns as ________.
A. terminals, non-terminals
B. operators, operands
C. non-terminals, terminals
D. keywords, operators
Correct Answer: C
Chapter: 16
Q550:
The rule F → ( E ) is applied when the parser encounters
A. )
B. (
C. +
D. id
Correct Answer: B
Chapter: 16
Q551:
The entry E’ → e in the table represents
A. No input required
B. A default fallback
C. Empty production
D. Error state
Correct Answer: C
Chapter: 16
Q552:
What does the parser output when a production is applied?
A. Non-terminal
B. Production used
C. Parsed string
D. None of these
Correct Answer: B
Chapter: 16
Q553:
2 + 4 * 6 results in ________ as per AST representation.
A. 14
B. 36
C. 26
D. None of the above
Correct Answer: A
Chapter: 16
Q554:
In the trace, which function is called after Factor::isPresent() returns true?
A. Eprime::isPresent()
B. Tprime::isPresent()
C. Expr::isPresent()
D. None of these
Correct Answer: B
Chapter: 16
Q555:
The predictive parser is also called
A. LL parser
B. Stack parser
C. Table-driven parser
D. All of the above
Correct Answer: D
Chapter: 16
Q556:
What value does s->nextToken() return for operator *?
A. 269
B. 267
C. 270
D. 268
Correct Answer: A
Chapter: 16
Q557:
To construct an AST, each subtree is built using
A. TreeNode
B. NodeTree
C. NodeRoot
D. TreeGraph
Correct Answer: A
Chapter: 16
Q558:
________ function handles grouping expressions with parentheses.
A. Factor::isPresent()
B. Term::isPresent()
C. Eprime::isPresent()
D. Tprime::isPresent()
Correct Answer: A
Chapter: 16
Q559:
Which grammar rule supports left-recursive removal for E’?
A. E' → E + T
B. E' → + T E'
C. E' → T + E
D. T → F T'
Correct Answer: B
Chapter: 16
Q560:
If M[X,a] = {X → UVW}, then stack top X is replaced by
A. UVW
B. WVU
C. None
D. Not replaced
Correct Answer: B

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now