Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Chapter: 7
Q221:
The algorithm used to convert RE to DFA is called ________.
A. Huffman’s Construction
B. Hopcroft’s Minimization
C. Thompson’s Construction
D. Regex Compiler
Correct Answer:
C
Chapter: 7
Q222:
Hopcroft’s algorithm is used to ________.
A. Build NFAs
B. Minimize states in DFA
C. Simulate parser
D. Remove ε-moves
Correct Answer:
B
Chapter: 7
Q223:
In C++, what data structure is used to represent transition tables of FA?
A. Linked List
B. 2D Array
C. Hash Map
D. Tree
Correct Answer:
B
Chapter: 7
Q224:
Which character represents the empty string in regular expressions?
A. e
B. ε
C. null
D. space
Correct Answer:
B
Chapter: 7
Q225:
What is the result of applying the Kleene star (*) to a regular expression R?
A. R or R² only
B. One occurrence of R
C. Any number of repetitions of R including none
D. Only one repetition
Correct Answer:
C
Chapter: 7
Q226:
The notation [a-z] in regular expressions means ________.
A. All lowercase characters from a to z
B. A single digit
C. A single symbol
D. A wildcard for uppercase characters
Correct Answer:
A
Chapter: 7
Q227:
The expression [^ab] matches ________.
A. Only 'a' or 'b'
B. Any character except 'a' and 'b'
C. Only capital A and B
D. Nothing
Correct Answer:
B
Chapter: 7
Q228:
Which of the following is an example of a valid identifier in most programming languages?
A. 123abc
B. _abc123
C. abc!23
D. #abc
Correct Answer:
B
Chapter: 7
Q229:
Which regular expression denotes an identifier?
A. [a-zA-Z]+
B. [a-zA-Z_][a-zA-Z0-9_]*
C. [0-9]+[a-zA-Z]
D. [a-z]*[0-9]*
Correct Answer:
B
Chapter: 7
Q230:
Which of the following strings is matched by the RE (ab)*?
A. ab
B. abab
D. All of these
Correct Answer:
D
Chapter: 7
Q231:
The language accepted by an automaton is a set of ________.
A. characters
B. strings
C. numbers
D. transitions
Correct Answer:
B
Chapter: 7
Q232:
A FA accepts a string if ________.
A. Final state is not reached
B. String is too long
C. A transition is missing
D. It ends in an accepting state
Correct Answer:
D
Chapter: 7
Q233:
Each RE can be converted into ________.
A. A function
B. A DFA only
C. A NFA only
D. An NFA, then DFA
Correct Answer:
D
Chapter: 7
Q234:
The RE a|b accepts which of the following strings?
A. a
B. b
C. c
D. d
Correct Answer:
A
Chapter: 7
Q235:
Which of the following best describes the structure of a DFA?
A. Tree
B. Graph with one transition per input
C. Stack
D. Binary search tree
Correct Answer:
B
Chapter: 7
Q236:
The final state in a finite automaton is called the ________.
A. start state
B. stop state
C. accepting state
D. transition state
Correct Answer:
C
Chapter: 7
Q237:
A regular expression is used to specify ________ in compiler design.
A. tokens
B. semantic rules
C. code generation
D. errors
Correct Answer:
A
Chapter: 7
Q238:
In regular expression, R+ means ________.
A. Zero or one R
B. One or more R
C. Exactly two R
D. All possible R strings
Correct Answer:
B
Chapter: 7
Q239:
The RE a(b|c)* denotes strings starting with a followed by ________.
A. zero or more a's
B. any characters only
C. b's or c's zero or more times
D. b's only
Correct Answer:
C
Chapter: 7
Q240:
The FA transition table helps implement a FA in which way?
A. Graph drawing
B. Simulating its execution
C. Generating syntax
D. Mapping symbols
Correct Answer:
B