Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Multiple Choice Questions

Q321: Flex generates code in
  • A: C/C++ only
  • B: Java only
  • C: Assembly
  • D: Python
View Answer
A

Q322: The longest matching token is selected by
  • A: Flex
  • B: Jlex
  • C: Parser
  • D: Lexical Analyzer
View Answer
D

Q323: What is the role of a scanner in a compiler?
  • A: To parse syntax
  • B: To identify tokens
  • C: To execute programs
  • D: To optimize code
View Answer
B

Q324: Which command is used to run the scanner on main.cpp file?
  • A: ./scanner main.cpp
  • B: lex main.cpp
  • C: lex
  • D: g++ main.cpp
View Answer
C

Q325: What does '259,void' represent in the scanner output?
  • A: Token type and token
  • B: Line number and variable
  • C: Data type and size
  • D: Line number and token
View Answer
A

Q326: Which token is returned by the Flex rule for "{"?
  • A: '}'
  • B: '['
  • C: '{'
  • D: '('
View Answer
C

Q327: Which Flex rule skips whitespace characters like tab and space?
  • A: [\t]+
  • B: [\s]+
  • C: [\t\f\v\r ]+
  • D: [ \n\t]+
View Answer
C

Q328: Which function is used to skip multi-line comments in Flex?
  • A: skip_multiline()
  • B: skip_comment()
  • C: skip_block()
  • D: remove_comment()
View Answer
B

Q329: Which symbol represents the start of a multi-line comment in C++?
  • A: //
  • B: /*
  • C: #
  • D:
View Answer
B

Q330: The Flex rule for the character '!' returns which token?
  • A: NOT
  • B: AND
  • C: OR
  • D: EQUAL
View Answer
A

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now