Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Multiple Choice Questions
Q1031: What are the two primary purposes of boolean expressions in programming languages?
- A: Computing logical values and conditional flow
- B: Storing data and loops
- C: Arithmetic calculations and strings
- D: Input/output operations
View Answer
A
Q1032: In the grammar of boolean expressions, what does E → E or E represent?
- A: Logical OR operation
- B: Logical AND operation
- C: Negation
- D: Parenthesis grouping
View Answer
A
Q1033: Which code is generated for the rule E → id1 relop id2 in syntax-directed translation?
- A: if id1 relop id2 goto E.true and goto E.false
- B: if id1 relop id2 goto E.true only
- C: goto E.false only
- D: no code generated
View Answer
A
Q1034: What does the function makelist(i) do in backpatching?
- A: Creates a list containing quadruple index i
- B: Merges two lists
- C: Emits a jump statement
- D: Returns the next label
View Answer
A
Q1035: In backpatching, what is the purpose of the merge(p1, p2) function?
- A: Concatenates two lists of goto statements
- B: Creates a new list
- C: Generates labels
- D: Fills jump targets
View Answer
B
Q1036: What is the role of the backpatch(p, i) function?
- A: Inserts label i as the target for each goto on list p
- B: Generates a new quadruple
- C: Merges two lists
- D: Deletes a list
View Answer
A
Q1037: In the boolean expression E → E1 and E2, what is assigned to E1.true?
- A: A new label
- B: E.false
- C: E.true
- D: Next quadruple
View Answer
A
Q1038: Fill in the blank: The semantic action { M.quad = nextquad() } associates M.quad with the _______.
- A: Index of the next quadruple
- B: Number of jumps
- C: Label name
- D: Variable
View Answer
A
Q1039: Which statement correctly describes E.true and E.false in syntax-directed translation?
- A: Lists of jumps with targets to be backpatched
- B: Variable names
- C: Operators
- D: Boolean values
View Answer
A
Q1040: What does the generated code for the expression "a < b or c < d and e < f" include?
- A: Multiple conditional gotos with labels
- B: Single goto statement
- C: Only if statements
- D: No control flow
View Answer
A