Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Multiple Choice Questions

Q291: The expression {L}({L}|{D})* is used to match what?
  • A: Integer numbers
  • B: Identifiers
  • C: Keywords
  • D: Operators
View Answer
B

Q292: What does the token TOK_NE represent?
  • A: <=>
  • B: =
  • C: ==
  • D: !=
View Answer
D

Q293: Which file contains the token definitions used by Flex?
  • A: tokens.cpp
  • B: tokdefs.h
  • C: lexer.h
  • D: tokmap.h
View Answer
B

Q294: Which token is represented by the keyword "void" in Flex?
  • A: TOK_INT
  • B: TOK_IF
  • C: TOK_VOID
  • D: TOK_ELSE
View Answer
C

Q295: What is the value of TOK_IF defined in tokdefs.h?
  • A: 2
  • B: 3
  • C: 5
  • D: 8
View Answer
B

Q296: Which token value is assigned to TOK_ID in tokdefs.h?
  • A: 111
  • B: 101
  • C: 10
  • D: 11
View Answer
A

Q297: Which of the following is a command to invoke Flex?
  • A: run flex
  • B: flex lex.l
  • C: flex -compile lex.l
  • D: build lex.l
View Answer
B

Q298: Which command compiles the output file from Flex?
  • A: gcc -c lex.cpp
  • B: g++ –c lex.cpp
  • C: clang lex.cpp
  • D: cc lex.cpp
View Answer
B

Q299: The final command to create executable file in Windows is
  • A: g++ –o lex.exe lex.o main.o
  • B: link lex.o main.o
  • C: g++ compile exe
  • D: compile –win –o lex.exe
View Answer
A

Q300: The main function uses which method to get token codes from scanner?
  • A: getToken()
  • B: YYText()
  • C: yylex()
  • D: getLex()
View Answer
C

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now