☑ MCQ PRACTICE

Compiler Design Unit 3

Practice objective questions for quick revision and examination preparation. Try answering each question before revealing the answer.

📚 Compiler Design
📖 Unit 3
🎯 MCQs
Compiler Design MCQs - Unit 3

Compiler Design MCQs - Unit 3

1

A syntax-directed definition (SDD) is a context-free grammar together with

A only tokens
B only a symbol table
C only machine code
D attributes and semantic rules
Correct Answer attributes and semantic rules
2

An attribute whose value is computed from the attribute values of its children is

A inherited
B global
C synthesized
D constant
Correct Answer synthesized
3

An attribute whose value is computed from its parent and siblings is

A synthesized
B inherited
C terminal
D static
Correct Answer inherited
4

An S-attributed definition uses only

A inherited attributes
B no attributes
C global variables
D synthesized attributes
Correct Answer synthesized attributes
5

In an L-attributed definition, an inherited attribute may depend on the parent and the

A siblings to its right only
B children only
C grandchildren only
D siblings to its left
Correct Answer siblings to its left
6

S-attributed definitions can be evaluated in

A top-down only
B random order
C reverse input order
D bottom-up (post-order) fashion
Correct Answer bottom-up (post-order) fashion
7

A dependency graph is used to find

A the number of tokens
B the size of the symbol table
C the machine registers
D a valid order of evaluating attributes
Correct Answer a valid order of evaluating attributes
8

A parse tree that shows the values of its attributes is called an

A annotated parse tree
B abstract tree
C binary tree only
D empty tree
Correct Answer annotated parse tree
9

A syntax-directed translation scheme is a grammar with

A no productions
B only attributes
C semantic actions embedded in the production bodies
D only tokens
Correct Answer semantic actions embedded in the production bodies
10

In a postfix SDT, the actions are placed

A at the right end of the production
B at the left end of the production
C in the middle only
D outside the grammar
Correct Answer at the right end of the production
11

A directed acyclic graph (DAG) for an expression helps to

A increase the number of nodes
B remove all operators
C store tokens
D identify common subexpressions
Correct Answer identify common subexpressions
12

In three-address code, each instruction contains at most

A two operators on the right side
B three operators on the right side
C no operands
D one operator on the right side
Correct Answer one operator on the right side
13

Three-address code can be implemented as

A quadruples, triples and indirect triples
B tokens, lexemes and patterns
C stacks, queues and trees
D bytes, words and pages
Correct Answer quadruples, triples and indirect triples
14

A quadruple has how many fields?

A two
B three
C four
D five
Correct Answer four
15

A triple has how many fields?

A two
B four
C three
D five
Correct Answer three
16

Indirect triples use

A a list of pointers to triples
B four fields per entry
C no pointers
D only registers
Correct Answer a list of pointers to triples
17

Type checking ensures that

A every variable has a short name
B operands are of compatible types for the operator
C the source file is small
D comments are removed
Correct Answer operands are of compatible types for the operator
18

A type conversion done automatically by the compiler is called

A implicit conversion (coercion)
B explicit cast
C overloading
D linking
Correct Answer implicit conversion (coercion)
19

Backpatching is used to

A remove dead code
B allocate registers
C fill in jump targets that are not known when the jump is generated
D scan the input
Correct Answer fill in jump targets that are not known when the jump is generated
20

Boolean expressions in control-flow statements are translated using

A no code at all
B jumping code
C only registers
D only the symbol table
Correct Answer jumping code
21

A switch statement can be implemented using

A a jump table or a sequence of conditional jumps
B only a for loop
C only a stack
D no jumps
Correct Answer a jump table or a sequence of conditional jumps
22

In three-address code for procedure calls, the instruction param x is used to

A declare a variable
B pass an actual parameter
C return a value
D end the program
Correct Answer pass an actual parameter
23

An advantage of intermediate code is that

A it makes the program run slower
B it removes the need for a parser
C it avoids type checking
D it makes the compiler easier to retarget to other machines
Correct Answer it makes the compiler easier to retarget to other machines
24

For a = b + c * d, the three-address code uses how many temporary variables?

A 1
B 3
C 2
D 4
Correct Answer 2
25

Two types are structurally equivalent if

A they have the same structure
B they have the same name only
C they are declared in the same line
D they use the same colour
Correct Answer they have the same structure

Fill in the Blanks

26 A syntax-directed definition is a context-free grammar with attributes and ______ rules.
Correct Answer semantic
27 An attribute computed from the attributes of its children is called ______.
Correct Answer synthesized
28 An attribute computed from its parent and siblings is called ______.
Correct Answer inherited
29 An S-attributed definition uses only ______ attributes.
Correct Answer synthesized
30 A ______ graph is used to decide the order of evaluating attributes.
Correct Answer dependency
31 A parse tree that shows the attribute values at each node is called an ______ parse tree.
Correct Answer annotated
32 A ______ for an expression identifies its common subexpressions.
Correct Answer DAG (directed acyclic graph)
33 In three-address code, there is at most ______ operator on the right side of an instruction.
Correct Answer one
34 Three-address code can be stored as quadruples, triples and ______.
Correct Answer indirect triples
35 A quadruple has ______ fields.
Correct Answer four
36 ______ is the technique of filling in jump targets after they become known.
Correct Answer Backpatching
37 A type conversion inserted automatically by the compiler is called ______ conversion.
Correct Answer implicit
38 In an L-attributed definition, an inherited attribute may depend on the parent and the ______ siblings.
Correct Answer left
39 Intermediate code is independent of the ______ machine.
Correct Answer target
40 Boolean expressions in control flow are translated using ______ code.
Correct Answer jumping
← Back to All MCQs