Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Multiple Choice Questions

Q361: Which keyword will return the token WHILE in Flex?
  • A: for
  • B: loop
  • C: while
  • D: until
View Answer
C

Q362: The C++ keyword 'const_cast' is mapped to which Flex token?
  • A: CAST
  • B: CONST
  • C: CONST_CAST
  • D: STATIC_CAST
View Answer
C

Q363: The token returned for the expression "++i" includes which operator?
  • A: ++
  • B: --
  • C: +=
  • D: +
View Answer
A

Q364: Identifiers in Flex must start with ______.
  • A: A digit
  • B: An operator
  • C: An alphabet or underscore
  • D: An asterisk
View Answer
C

Q365: Which of the following is not a valid C++ keyword defined in Flex rules?
  • A: operator
  • B: register
  • C: package
  • D: typedef
View Answer
C

Q366: Flex is primarily used in which phase of a compiler?
  • A: Code generation
  • B: Semantic analysis
  • C: Lexical analysis
  • D: Optimization
View Answer
C

Q367: What type of error occurs when code follows syntax rules but the meaning is incorrect?
  • A: Semantic error
  • B: Syntax error
  • C: Runtime error
  • D: Linker error
View Answer
A

Q368: What is missing at the end of 'sum = sum+i' in the given C++ code?
  • A: Semicolon
  • B: Parenthesis
  • C: Braces
  • D: Colon
View Answer
A

Q369: What role does the parser play in a compiler?
  • A: It checks syntax validity
  • B: It executes the code
  • C: It allocates memory
  • D: It manages input/output
View Answer
A

Q370: Which formal grammar is typically used to represent syntax of programming languages?
  • A: Regular Grammar
  • B: Context-Free Grammar
  • C: Unrestricted Grammar
  • D: Regular Expression
View Answer
B

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now