Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Multiple Choice Questions
Q411: What do interior nodes in a parse tree represent?
- A: Terminals
- B: Non-terminals
- C: Operators
- D: Operands
View Answer
B
Q412: Which derivation starts from the leftmost non-terminal in the parse tree?
- A: Rightmost derivation
- B: Leftmost derivation
- C: Top-down parsing
- D: Bottom-up parsing
View Answer
B
Q413: In the expression x - 2 * y, which operator has higher precedence?
- A: Subtraction
- B: Multiplication
- C: Addition
- D: Division
View Answer
B
Q414: To encode operator precedence in grammar, what is created for each precedence level?
- A: Operator
- B: Terminal
- C: Non-terminal
- D: Keyword
View Answer
C
Q415: Which parsing technique starts at the root and works toward the leaves?
- A: Bottom-up parsing
- B: Leftmost derivation
- C: Top-down parsing
- D: Rightmost derivation
View Answer
C
Q416: What problem does ambiguous grammar cause?
- A: Multiple parse trees for same input
- B: No parse trees
- C: Parsing failure
- D: No ambiguity
View Answer
A
Q417: Which of the following is a property of context-free grammars?
- A: Non-terminals appear anywhere
- B: Terminals appear on left side
- C: Non-terminals appear alone on left side
- D: Terminals appear on right side
View Answer
C
Q418: What is the correct interpretation of the rule A → a in context-free grammars?
- A: A can be replaced by a anywhere
- B: A can be replaced only in specific contexts
- C: A must not be replaced
- D: A is terminal
View Answer
A
Q419: Which grammar type requires context before and after a non-terminal for replacement?
- A: Context-free
- B: Context-sensitive
- C: Unambiguous
- D: Regular
View Answer
B
Q420: In the ambiguous if-then-else grammar, the "else" is conventionally matched with which "if"?
- A: The outermost if
- B: The most recent unmatched if
- C: The first if
- D: The last if
View Answer
B