Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Chapter: 2
Q61:
What is the output of the parser for a legal program?
A. Tokens only
B. Error messages only
C. Intermediate Representation
D. Compiler report
Correct Answer: C
Chapter: 2
Q62:
The intermediate representation produced by the compiler front-end is used by the ______.
A. Hardware
B. Linker
C. Back end
D. Editor
Correct Answer: C
Chapter: 2
Q63:
The parser assists in ______ analysis.
A. Lexical
B. Semantic
C. Instructional
D. Code
Correct Answer: B
Chapter: 2
Q64:
A context-free grammar is defined by the tuple G = (S, N, T, ___)?
A. R
B. Rules
C. Tokens
D. P
Correct Answer: D
Chapter: 2
Q65:
The terminal set T includes which of the following?
A. goal
B. id
C. expr
D. term
Correct Answer: B
Chapter: 2
Q66:
What will be the first token produced from input “x = x + y”?
A. <id, x>
B. <assign, =>
C. <id, x>
D. <op, +>
Correct Answer: A
Chapter: 2
Q67:
Which of the following is NOT part of the compiler front end?
A. Scanner
B. Parser
C. Error handler
D. Code generator
Correct Answer: D
Chapter: 2
Q68:
The component that maps IR to machine code is called the ______.
A. Scanner
B. Parser
C. Back end
D. Semantic module
Correct Answer: C
Chapter: 2
Q69:
The sentence “x + 2 - y” is built in CFG using repeated ______.
A. Translation
B. Backtracking
C. Substitution
D. Recursion
Correct Answer: C
Chapter: 2
Q70:
Which module in the compiler produces error messages for illegal code?
A. Back end
B. Scanner
C. Parser
D. Assembler
Correct Answer: C
Chapter: 3
Q71:
What type of tree is used to represent the full derivation in a compiler?
A. Parse tree
B. Abstract syntax tree
C. Decision tree
D. Binary tree
Correct Answer: A
Chapter: 3
Q72:
What does a parse tree capture during compilation?
A. Errors
B. All rewrite steps during derivation
C. Token mapping
D. Optimization steps
Correct Answer: B
Chapter: 3
Q73:
To extract derivation from a parse tree, we start from ______.
A. Leaf nodes
B. Tokens
C. Root node
D. Grammar rules
Correct Answer: C
Chapter: 3
Q74:
The AST for expression x + 2 - y omits ______ from the parse tree.
A. Operators
B. Derivation details
C. Identifiers
D. Constants
Correct Answer: B
Chapter: 3
Q75:
An AST is an example of ______ in a compiler.
A. Source code
B. Token
C. Intermediate Representation
D. Assembler instruction
Correct Answer: C
Chapter: 3
Q76:
Which tree represents the grammatical structure without derivation steps?
A. Syntax tree
B. Parse tree
C. Abstract Syntax Tree
D. Binary tree
Correct Answer: C
Chapter: 3
Q77:
Which of the following is a more concise representation?
A. Parse tree
B. AST
C. Error tree
D. Stack tree
Correct Answer: B
Chapter: 3
Q78:
The AST for expression x + 2 – y contains how many operator nodes?
A. 1
B. 2
C. 3
Correct Answer: B
Chapter: 3
Q79:
Which of the following best describes AST?
A. Graphical representation of source code
B. Summary of syntax and semantics
C. Summary of grammatical structure
D. Mapping of tokens to expressions
Correct Answer: C
Chapter: 3
Q80:
The back end of the compiler translates IR into ______.
A. Bytecode
B. Assembly code
C. Machine code
D. Pseudocode
Correct Answer: C

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now