Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Chapter: 2
Q41:
Which part of the compiler generates target machine code from IR?
A. Front end
B. Back end
C. Scanner
D. Parser
Correct Answer: B
Chapter: 2
Q42:
What is the complexity class of most front-end compiler algorithms?
A. NP-complete
B. Exponential
C. Polynomial
D. Constant
Correct Answer: C
Chapter: 2
Q43:
Most back-end algorithms in a compiler are _______.
A. Polynomial
B. NP-complete
C. Linear
D. Time-independent
Correct Answer: B
Chapter: 2
Q44:
The front end of a compiler produces ______ for legal programs.
A. Object code
B. Assembly code
C. Intermediate Representation (IR)
D. Binary code
Correct Answer: C
Chapter: 2
Q45:
Which module of the compiler converts character streams to tokens?
A. Parser
B. Scanner
C. Generator
D. Analyzer
Correct Answer: B
Chapter: 2
Q46:
Which module processes tokens to construct syntax trees and checks grammar?
A. Scanner
B. Parser
C. Assembler
D. Interpreter
Correct Answer: B
Chapter: 2
Q47:
The scanner outputs a stream of ______.
A. Lexemes
B. Tokens
C. Statements
D. Instructions
Correct Answer: B
Chapter: 2
Q48:
The parser is responsible for recognizing ______ syntax.
A. Semantic
B. Grammar
C. Programming
D. Context-free
Correct Answer: D
Chapter: 2
Q49:
A token is composed of ______.
A. Only keyword
B. Only identifier
C. A token type and a word
D. An operator and a variable
Correct Answer: C
Chapter: 2
Q50:
Which type of grammar is used to specify programming language syntax?
A. Context-free grammar
B. Regular grammar
C. Unrestricted grammar
D. Linear grammar
Correct Answer: A
Chapter: 2
Q51:
CFG stands for _______.
A. Context-Free Generator
B. Context-Free Grammar
C. Context-Fixed Grammar
D. Code Format Grammar
Correct Answer: B
Chapter: 2
Q52:
In context-free grammar, S represents ______.
A. Scanner
B. Start symbol
C. Statement
D. Source
Correct Answer: C
Chapter: 2
Q53:
Which is NOT a terminal symbol in the given CFG?
A. +
B. id
C. goal
D. number
Correct Answer: C
Chapter: 2
Q54:
Which of the following is a non-terminal symbol?
A. goal
B. +
C. id
D. number
Correct Answer: A
Chapter: 2
Q55:
The CFG for arithmetic expressions includes how many productions?
A. 5
B. 6
C. 7
D. 8
Correct Answer: C
Chapter: 2
Q56:
Which of the following is a valid token type?
A. statement
B. number
C. procedure
D. method
Correct Answer: B
Chapter: 2
Q57:
In token representation <id, x>, 'id' is the ______.
A. word
B. token
C. type
D. part of speech
Correct Answer: C
Chapter: 2
Q58:
The sentence “x + 2 - y” is derived using ______.
A. Backtracking
B. Rightmost derivation
C. Leftmost derivation
D. Context-sensitive parsing
Correct Answer: C
Chapter: 2
Q59:
A production rule in CFG can be defined as ______.
A. Operator
B. Rewrite rule
C. Assembler directive
D. Instruction set
Correct Answer: B
Chapter: 2
Q60:
x = x + y is converted by the scanner into how many tokens?
A. 3
B. 4
C. 5
D. 6
Correct Answer: C

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now