Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Chapter: 6
Q201:
Which of these is not a token category?
A. Identifiers
B. Keywords
C. Integers
D. Parsers
Correct Answer:
D
Chapter: 6
Q202:
The RE (a|b)* accepts ______.
A. Strings with one a only
B. Strings with one b only
C. Strings with a’s and b’s in any combination
D. Strings without a and b
Correct Answer:
C
Chapter: 6
Q203:
The finite automaton that accepts any number of 1s followed by a single 0 will reject ______.
A. 1110
B. 1101
C. 11110
D. 10
Correct Answer:
B
Chapter: 6
Q204:
The language consisting of all Java programs is built over which alphabet?
A. ASCII
B. Binary
C. Hexadecimal
D. Unicode
Correct Answer:
A
Chapter: 6
Q205:
______ is used to group sub-expressions in regular expressions.
A. |
B. ( )
C. *
D. +
Correct Answer:
B
Chapter: 6
Q206:
In the RE a*, how many times can 'a' appear in a string?
A. Exactly once
B. Zero or more times
C. Only twice
D. Only in pairs
Correct Answer:
B
Chapter: 6
Q207:
In regular expressions, what does R? represent?
A. Zero or one R
B. One or more R
C. Exactly one R
D. Infinite R
Correct Answer:
A
Chapter: 6
Q208:
The RE ab means that string must start with a and be followed by ______.
A. Any string
B. a
C. b
D. another ab
Correct Answer:
B
Chapter: 6
Q209:
Which is an example of a valid identifier in C++?
A. 123name
B. _name
C. main@
D. __init__
Correct Answer:
D
Chapter: 6
Q210:
In REs, which symbol is used for alternation (either-or)?
A. +
B. |
C. *
D. ?
Correct Answer:
B
Chapter: 7
Q211:
A transition table in Finite Automata is used to ________.
A. track memory usage
B. encode transitions between states
C. draw syntax trees
D. manage symbols
Correct Answer:
B
Chapter: 7
Q212:
Which programming construct is used to simulate a Finite Automaton in C++?
A. Function pointer
B. Transition table
C. Stack
D. Array
Correct Answer:
B
Chapter: 7
Q213:
What is the role of the variable `state` in the C++ FA simulator?
A. It stores error codes
B. It keeps input characters
C. It tracks current state of FA
D. It stores string length
Correct Answer:
C
Chapter: 7
Q214:
What does the `accept_states[state]` return in the FA simulation?
A. A list of accepted languages
B. The transition path
C. The current input state
D. If the string is accepted or not
Correct Answer:
D
Chapter: 7
Q215:
In a DFA, how many transitions can exist per input symbol per state?
A. Zero
B. One
C. Multiple
D. Unlimited
Correct Answer:
B
Chapter: 7
Q216:
A Nondeterministic Finite Automaton (NFA) may have _______ for a given input.
A. only one path
B. two errors
C. multiple transitions
D. zero memory
Correct Answer:
C
Chapter: 7
Q217:
Which of the following is true for DFA?
A. It can make ε-moves
B. It allows multiple transitions for a symbol
C. Only one transition per symbol
D. None of the above
Correct Answer:
C
Chapter: 7
Q218:
In NFA, what does an ε-move represent?
A. A failure state
B. An error
C. A transition without consuming input
D. A final state
Correct Answer:
C
Chapter: 7
Q219:
Which of the following has a more compact representation for a regular expression?
A. DFA
B. NFA
C. Transition Table
D. Stack
Correct Answer:
B
Chapter: 7
Q220:
What does RE stand for in compiler construction?
A. Regular Entry
B. Recursive Evaluation
C. Regular Expression
D. Relational Element
Correct Answer:
C