Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Chapter: 6
Q181:
The regular expression a|b denotes which of the following?
A. Strings containing only 'a'
B. Strings containing 'a' or 'b'
C. Strings containing only 'b'
D. Strings containing 'ab'
Correct Answer: B
Chapter: 6
Q182:
What does the regular expression (ab)* accept?
A. Only 'ab'
B. Any number of 'ab' repetitions
C. Only 'a'
D. Only 'b'
Correct Answer: B
Chapter: 6
Q183:
Which of the following denotes zero or more repetitions of a regular expression R?
A. R+
B. R?
C. R*
D. R/
Correct Answer: C
Chapter: 6
Q184:
The expression [a-z] matches _______.
A. All capital letters
B. All numbers
C. Lowercase letters from a to z
D. Only vowels
Correct Answer: C
Chapter: 6
Q185:
The notation [^ab] matches _______.
A. Only 'a' or 'b'
B. Nothing but 'a' or 'b'
C. Everything except 'a' and 'b'
D. Only lowercase letters
Correct Answer: C
Chapter: 6
Q186:
In programming languages, which token is matched by the expression [a-zA-Z_][a-zA-Z0-9_]*?
A. Keyword
B. Integer
C. Identifier
D. String
Correct Answer: C
Chapter: 6
Q187:
The acceptor for regular languages is implemented using _______.
A. Context-free grammar
B. Finite Automata
C. Pushdown Automata
D. Turing Machine
Correct Answer: B
Chapter: 6
Q188:
Which component checks if a string belongs to the language defined by a regular expression?
A. Generator
B. Compiler
C. Acceptor
D. Translator
Correct Answer: C
Chapter: 6
Q189:
The FA accepts a string if the transition from start state ends at _______.
A. Dead state
B. Error state
C. Any state
D. Accepting state
Correct Answer: D
Chapter: 6
Q190:
The number 123 is matched by which regular expression?
A. digit digit*
B. [a-z]*
C. [a-zA-Z_]
D. R+
Correct Answer: A
Chapter: 6
Q191:
The regular expression a|b generates the strings ______.
A. a only
B. b only
C. a and b
D. ab
Correct Answer: C
Chapter: 6
Q192:
Finite Automaton consists of ______.
A. Only accepting states
B. Only start state
C. A set of states, transitions, and input alphabet
D. Only input alphabet
Correct Answer: C
Chapter: 6
Q193:
Which is an invalid regular expression extension?
A. R+
B. R?
C. R^
D. R*
Correct Answer: C
Chapter: 6
Q194:
Regular expressions are useful for ______ in compiler design.
A. Parsing
B. Optimization
C. Token generation
D. Code generation
Correct Answer: C
Chapter: 6
Q195:
The FA that accepts only '1' will reject ______.
A. 1
B. 11
D. Empty string
Correct Answer: C
Chapter: 6
Q196:
In formal language theory, ε represents _______.
A. Concatenation
B. Empty string
C. Error
D. Alphabet
Correct Answer: B
Chapter: 6
Q197:
What will be the result of L(a|ε)b?
A. Only 'b'
B. Only 'ab'
C. 'ab' and 'b'
D. Only 'a'
Correct Answer: C
Chapter: 6
Q198:
Which regular expression matches a positive integer?
A. [a-z]+
B. digit digit*
C. [a-zA-Z_][a-zA-Z0-9_]*
D. [a-z]{2,}
Correct Answer: B
Chapter: 6
Q199:
The expression digit digit* accepts ______.
A. Single character only
B. Any alphabet
C. All integers
D. Only even numbers
Correct Answer: C
Chapter: 6
Q200:
The token class for "if" in programming is ______.
A. Identifier
B. Keyword
C. Operator
D. Integer
Correct Answer: B

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now