wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Compiler Design Worksheet MCQs

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

Which data structure allows efficient insertion and lookup in a symbol table for compilers?

a)

Linked List

b)

Hash Table

c)

Binary Tree

d)

Array

2.

In block-structured languages, symbol tables are usually managed using:

a)

Queue of tables

b)

Stack of tables

c)

Tree of tables

d)

Array of tables

3.

What does a symbol table not store?

a)

Variable names

b)

Data types

c)

Intermediate code

d)

Memory locations

4.

When two identifiers hash to the same slot, the situation is handled using:

a)

Separate chaining

b)

Linear regression

c)

Recursive parsing

d)

Direct mapping

5.

In Syntax Directed Translation, the semantic rules are associated with:

a)

Tokens

b)

Grammar productions

c)

Intermediate code

d)

Symbol table

6.

An S-attributed definition contains only:

a)

Synthesized attributes

b)

Inherited attributes

c)

Dynamic attributes

d)

None of the above

7.

An L-attributed definition can contain:

a)

Only synthesized attributes

b)

Both synthesized and certain inherited attributes

c)

Only inherited attributes

d)

None

8.

Which optimization replaces variables with known constant values?

a)

Constant folding

b)

Constant propagation

c)

Dead code elimination

d)

Loop unrolling

9.

Which of the following expressions can be folded at compile time?

a)

x + y

b)

3 + 5

c)

a + 2

d)

p * q

10.

Constant propagation cannot be applied if:

a)

Variable is assigned once

b)

Variable is assigned inside a loop

c)

Variable is global

d)

Variable is used after assignment

11.

Constant propagation uses which type of data flow analysis?

a)

Forward flow

b)

Backward flow

c)

Lateral flow

d)

Bidirectional

12.

PRE aims to:

a)

Eliminate all redundant computations

b)

Eliminate only partially redundant expressions

c)

Eliminate loop-invariant computations

d)

Remove dead code

13.

An expression is partially redundant if:

a)

It occurs on every path

b)

It occurs on no path

c)

It occurs on some but not all paths

d)

It occurs only once

14.

How does PRE differ from common subexpression elimination (CSE)?

a)

PRE handles loops

b)

PRE removes all redundancies

c)

PRE works across paths

d)

CSE is more general

15.

PRE typically operates on:

a)

Lexical tokens

b)

Parse trees

c)

Basic blocks

d)

Symbol tables