Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Multiple Choice Questions

Q171: The code `if( idChar(next) ) return readId();` checks for a _______.
  • A: number
  • B: string
  • C: valid identifier character
  • D: operator
View Answer
C

Q172: Which of the following is NOT part of a token?
  • A: Word
  • B: Role
  • C: Type
  • D: Length
View Answer
D

Q173: The look-ahead character in Lexer helps in ______.
  • A: reading strings
  • B: checking syntax
  • C: deciding token boundaries
  • D: matching grammar rules
View Answer
C

Q174: What happens if the character is not part of a valid identifier in `readId()`?
  • A: It is stored in buffer
  • B: It is skipped
  • C: It ends the identifier
  • D: A token is returned
View Answer
D

Q175: What is the most popular method for specifying tokens in lexical analysis?
  • A: Context-Free Grammars
  • B: Regular Languages
  • C: Turing Machines
  • D: Fuzzy Logic
View Answer
B

Q176: Regular languages are preferred for token specification because they are _______.
  • A: complex and theoretical
  • B: easy and intuitive
  • C: based on difficult logic
  • D: used in database queries
View Answer
B

Q177: The alphabet in formal language theory is _______.
  • A: A complete sentence
  • B: A syntax rule
  • C: A set of characters
  • D: A set of rules
View Answer
C

Q178: Which of the following is an example of a language over ASCII?
  • A: English Sentence
  • B: C++ Program
  • C: Binary Code
  • D: HTML Tag
View Answer
B

Q179: A regular expression describes _______.
  • A: A programming loop
  • B: A conditional expression
  • C: A regular language
  • D: Grammar rules
View Answer
C

Q180: Which notation is used to denote the language defined by a regular expression A?
  • A: L(A)
  • B: R(A)
  • C: Reg(A)
  • D: Expr(A)
View Answer
A

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now