Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Multiple Choice Questions

Q971: The main advantage of a DAG over an AST is that it _______.
  • A: avoids duplication
  • B: includes all parse details
  • C: uses more nodes
  • D: is less concise
View Answer
A

Q972: The semantic rule E โ†’ E1 + E2 in AST creation uses the function ______ to create a node.
  • A: mknode(โ€˜+โ€™, E1.nptr, E2.nptr)
  • B: mkleaf(โ€˜+โ€™, E1.nptr)
  • C: mknode(โ€˜*โ€™, E1.nptr, E2.nptr)
  • D: mkleaf(โ€˜numโ€™, E1.val)
View Answer
A

Q973: The function used to create leaf nodes in AST is called ______.
  • A: mkleaf
  • B: mknode
  • C: mkbranch
  • D: mkroot
View Answer
A

Q974: In YACC syntax, the semantic rule for E โ†’ E1 * E2 is written as ______.
  • A: $$.nptr = mknode(โ€˜*โ€™, $1.nptr, $3.nptr)
  • B: $$.nptr = mkleaf(โ€˜*โ€™, $1.nptr)
  • C: $$.nptr = mknode(โ€˜+โ€™, $1.nptr, $3.nptr)
  • D: $$.nptr = $1.nptr
View Answer
A

Q975: Three-address code is an example of which type of IR?
  • A: Linear IR
  • B: Graphical IR
  • C: Hybrid IR
  • D: Parse Tree
View Answer
A

Q976: Stack-machine code is also known as ______.
  • A: one-address code
  • B: two-address code
  • C: three-address code
  • D: no-address code
View Answer
A

Q977: Stack-machine code primarily uses ______ to operate on operands.
  • A: operand stack
  • B: registers
  • C: memory addresses
  • D: variables
View Answer
A

Q978: Smalltalk-80 and Java byte-codes are examples of ______ IR.
  • A: stack-machine
  • B: three-address
  • C: hybrid
  • D: parse tree
View Answer
A

Q979: In three-address code, the general form of an operation is ______.
  • A: x โ† y op z
  • B: op x y z
  • C: y โ† x op z
  • D: z โ† x op y
View Answer
A

Q980: Linear IRs execute instructions in the order of ______.
  • A: appearance
  • B: dependency
  • C: parallel
  • D: random
View Answer
A

Test Your Knowledge

Take a timed quiz on Compiler Construction

๐Ÿš€ Start Quiz Now