Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Chapter: 14
Q481:
The function Goal() returns true only if Expr() returns true and token equals ________.
A. EOF
B. NULL
C. ε
D. $
Correct Answer: A
Chapter: 14
Q482:
In recursive descent parsing, each non-terminal corresponds to a ________.
A. function
B. class
C. method
D. object
Correct Answer: A
Chapter: 14
Q483:
The method isPresent() in the C++ parser class returns a ________.
A. boolean
B. value
C. node
D. tree
Correct Answer: A
Chapter: 14
Q484:
The class Expr inherits from the base class ________.
A. NonTerminal
B. Scanner
C. TreeNode
D. Parser
Correct Answer: A
Chapter: 14
Q485:
In object-oriented recursive descent parsing, parse tree nodes are typically stored as ________.
A. pointers
B. integers
C. strings
D. arrays
Correct Answer: A
Chapter: 14
Q486:
The parser code snippet: if(token ∈ FIRST(b2)) find a b2 and return true; else error and return false; represents a ________.
A. decision structure
B. loop
C. assignment
D. function call
Correct Answer: A
Chapter: 14
Q487:
Which of the following is NOT part of LL(1) parsing?
A. Using look-ahead tokens
B. Left-to-right scanning
C. Left-most derivation
D. Right-most derivation
Correct Answer: D
Chapter: 14
Q488:
In the recursive descent parser, the token_type op can be PLUS or MINUS in the function ________.
A. Eprime
B. Expr
C. Term
D. Factor
Correct Answer: A
Chapter: 14
Q489:
In C++ recursive descent parsing, the constructor of class NonTerminal accepts a ________.
A. Scanner pointer
B. Parse tree
C. Token
D. Grammar
Correct Answer: A
Chapter: 14
Q490:
To maintain LL(1) property, productions for the same non-terminal must have disjoint ________.
A. FIRST sets
B. FOLLOW sets
C. Terminals
D. Non-terminals
Correct Answer: A
Chapter: 14
Q491:
The term 'recursive descent' refers to parsing from ________ downwards.
A. root
B. to leaves
C. leaves
D. to root
Correct Answer: A
Chapter: 14
Q492:
In the grammar fragment expr → term expr', the symbol expr' represents ________.
A. a continuation of expr
B. an alternative term
C. a terminal
D. a non-terminal
Correct Answer: D
Chapter: 14
Q493:
The method isPresent() is typically ________ in C++ classes for parsing.
A. abstract
B. implemented
C. virtual
D. static
Correct Answer: C
Chapter: 14
Q494:
In LL(1) parsing, error detection occurs when the current token is not in any ________ set of the expected productions.
A. FIRST
B. FOLLOW
C. EOF
D. START
Correct Answer: A
Chapter: 14
Q495:
Which of the following operators appear in the term production in the example grammar?
A. * and /
B. + and -
C. = and !=
D. < and >
Correct Answer: A
Chapter: 14
Q496:
Which symbol in the grammar helps the parser decide the correct production when ε-productions are present?
A. FIRST+
B. FIRST
C. FOLLOW
D. EOF
Correct Answer: A
Chapter: 14
Q497:
The C++ class Factor inherits from ________.
A. NonTerminal
B. Expr
C. Term
D. Tprime
Correct Answer: A
Chapter: 14
Q498:
In recursive descent parsing, mutual recursion between functions represents ________.
A. grammar productions
B. token scanning
C. error handling
D. lexer functions
Correct Answer: A
Chapter: 14
Q499:
The class Eprime constructor requires a pointer to a ________.
A. TreeNode
B. Scanner
C. Token
D. Parser
Correct Answer: A
Chapter: 15
Q500:
Which class is responsible for parsing expressions within parentheses?
A. Term
B. Expr
C. Factor
D. Tprime
Correct Answer: C

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now