Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Multiple Choice Questions

Q141: What is the output of a scanner in lexical analysis?
  • A: Parse tree
  • B: Tokens
  • C: Source code
  • D: Errors
View Answer
B

Q142: A token is a _______ category in a sentence of a language.
  • A: semantic
  • B: syntactic
  • C: lexical
  • D: grammatical
View Answer
B

Q143: In the sentence “He wrote the program”, “wrote” is classified as a ______.
  • A: subject
  • B: verb
  • C: object
  • D: conjunction
View Answer
B

Q144: In programming, “if”, “else”, and “while” are categorized as ________.
  • A: keywords
  • B: identifiers
  • C: symbols
  • D: operators
View Answer
A

Q145: What would be the token for the word 'b' in the sentence `if(b == 0)`?
  • A: Keyword
  • B: Identifier
  • C: Operator
  • D: Integer
View Answer
B

Q146: Which of the following is a valid float token?
  • A: 1000
  • B: 0.0034
  • C: error
  • D: ==
View Answer
B

Q147: Which of the following is NOT a token type?
  • A: Keywords
  • B: Identifiers
  • C: Statements
  • D: Integers
View Answer
C

Q148: Which class is responsible for generating tokens in the provided C++ code?
  • A: Token
  • B: Scanner
  • C: Parser
  • D: Lexer
View Answer
D

Q149: The Lexer class uses _______ to look ahead for the next character.
  • A: next
  • B: prev
  • C: curr
  • D: lookahead
View Answer
A

Q150: In the Lexer class, what function is used to recognize identifiers?
  • A: readToken()
  • B: readId()
  • C: readIdentifier()
  • D: readChar()
View Answer
B

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now