Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Multiple Choice Questions

Q501: Which operator(s) does `Eprime::isPresent()` specifically handle?
  • A: MULTIPLICATION and DIVISION
  • B: LPAREN and RPAREN
  • C: PLUS and MINUS
  • D: ID and NUM
View Answer
C

Q502: In `Tprime::isPresent()`, the method returns false when the next token is not __________.
  • A: ID or NUM
  • B: PLUS or MINUS
  • C: MUL or DIV
  • D: LPAREN or RPAREN
View Answer
C

Q503: The function `Factor::isPresent()` checks for which two types of tokens initially?
  • A: ID and NUM
  • B: MUL and DIV
  • C: PLUS and MINUS
  • D: LPAREN and RPAREN
View Answer
A

Q504: What will happen if the expected closing parenthesis is not found in Factor?
  • A: The function returns true
  • B: The program skips the token
  • C: A syntax error is thrown
  • D: It creates a new node
View Answer
C

Q505: What does the `tree` variable typically store in these classes?
  • A: An integer value
  • B: A boolean flag
  • C: An AST node
  • D: A token list
View Answer
C

Q506: The object `op1` in `Expr::isPresent()` is an instance of which class?
  • A: Expr
  • B: Factor
  • C: Tprime
  • D: Term
View Answer
D

Q507: In the context of this code, the abbreviation AST stands for __________.
  • A: Abstract Syntax Tree
  • B: Application Syntax Token
  • C: Advanced Syntax Tree
  • D: All Syntax Tokens
View Answer
A

Q508: Which of the following constructs recursive parsing using itself in the grammar implementation?
  • A: TreeNode
  • B: Factor
  • C: Tprime
  • D: Eprime
View Answer
D

Q509: The `syntaxError(s)` function is called when ________.
  • A: A valid token is found
  • B: Parsing completes successfully
  • C: A required component is missing in the expression
  • D: AST creation is complete
View Answer
C

Q510: The method `advance()` is used to __________.
  • A: Go back one token
  • B: Read a new file
  • C: Move to the next token
  • D: Save a variable
View Answer
C

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now