Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Multiple Choice Questions
Q381: Which of the following is a non-terminal in the expression grammar?
- A: +
- B: -
- C:
- D: *
View Answer
C
Q382: Fill in the blank: A parser must distinguish between valid and ______ sequences of tokens.
- A: Invalid
- B: Syntactical
- C: Grammatical
- D: Complete
View Answer
A
Q383: What is the function return type in 'int* foo(int i, int j)'?
- A: Integer pointer
- B: Integer
- C: Character
- D: String
View Answer
A
Q384: Which statement about parsing is true?
- A: It discovers a derivation for a sentence
- B: It executes program code
- C: It allocates variables
- D: It performs memory management
View Answer
A
Q385: Which of the following is NOT a terminal symbol?
- A: '+'
- B: 'id'
- C: 'expr'
- D: '*'
View Answer
C
Q386: Which is the correct production rule for op in the given grammar?
- A: op -> + | - | * | /
- B: op -> num | id
- C: op -> expr
- D: op -> baa
View Answer
A
Q387: In the for loop 'for(k=0; i < j; j++)', what semantic error is present?
- A: Incrementing the wrong variable
- B: Incorrect syntax
- C: Wrong data type
- D: Missing semicolon
View Answer
A
Q388: Which grammar rule corresponds to 'expr -> num'?
- A: Rule 1
- B: Rule 2
- C: Rule 3
- D: Rule 4
View Answer
B
Q389: What is the significance of a parse tree?
- A: Shows evaluation order
- B: Allocates memory
- C: Executes code
- D: Checks data types
View Answer
A
Q390: Which of the following is NOT a property of regular languages?
- A: Expressive enough for programming syntax
- B: Recognized by finite automata
- C: Do not have memory of visited states
- D: Closed under union
View Answer
A