Explore topic-wise MCQs in Compilers.

This section includes 13 Mcqs, each offering curated multiple-choice questions to sharpen your Compilers knowledge and support exam preparation. Choose a topic below to get started.

1.

For a statement S in a program, in the context of liveness analysis, the following sets are defined:USE(S): the set of variables used in SIN(S): the set of variables that are live at the entry of SOUT(S): the set of variables that are live at the exit of SConsider a basic block that consists of two statements, S1 followed by S2.Which one of the following statements is correct?

A. OUT(S1) = USE(S1) ∪ IN(S2)
B. OUT(S1) = IN(S2)
C. OUT(S1) = IN(S1) ∪ USE(S1)
D. OUT(S1) = IN(S2) ∪ USE(S2)
Answer» C. OUT(S1) = IN(S1) ∪ USE(S1)
2.

Peephole optimization is a:

A. Loop optimization
B. Local optimization
C. Constant folding
D. Data flow analysis
Answer» C. Constant folding
3.

Consider evaluating the following expression tree on a machine with load-store Architecture in which memory can be accessed only through load and store instructions. The variables a, b, c, d and e are initially stored in memory. The binary operators used in this expression tree can be evaluated by the machine only when the operands are in registers. The instructions produce result only in a register. If no intermediate results can be stored in memory, what is the minimum number of registers needed to evaluate this expression?

A. 2
B. 9
C. 5
D. 3
Answer» E.
4.

Peephole optimization is a form of

A. Loop optimization
B. Local optimization
C. Constant folding
D. Data flow analysis
Answer» B. Local optimization
5.

Consider the code segmentint i, j, x, y, m, n;n=20;for (i = 0, i < n; i++){ for (j = 0; j < n; j++) { if (i % 2) { x + = ((4*j) + 5*i); y += (7 + 4*j); } }}m = x + y;Which one of the following is false?

A. The code contains loop invariant computation
B. There is scope of common sub-expression elimination in this code
C. There is scope of strength reduction in this code
D. There is scope of dead code elimination in this code
Answer» E.
6.

Consider the following ANSI C code segment:z = x + 3 + y -> f1 + y -> f2;for (i = 0; i < 200; i = i + 2){if (z > i) {P = p + x + 3;q = q + y -> f2;} else {p = p + y -> f2;q = q + x + 3;}}Assume that the variable y points to a struct (allocated on the heap) containing two fields f1 and f2, and the local variables x, y, z, p, g, and i are allotted registers. Common sub-expression elimination (CSE) optimization is applied on the code. The number of addition and dereference operations (of the form y -> f1 or y -> f2 ) in the optimized code, respectively, are:

A. 203 and 2
B. 403 and 102
C. 303 and 102
D. 303 and 2
Answer» E.
7.

Relocating_bits_used_by_relocating_loader_are_specified_by$

A. Relocation loader itself
B. Linker
C. Assembler
D. Macro Processor
Answer» C. Assembler
8.

The address code involve?

A. Exactly 3 address
B. At most Three address
C. No unary operators
D. None of the mentioned
Answer» E.
9.

( Z,* ) be a structure, and * is defined by n * m =maximum ( n , m ) Which of the following statements is true for ( Z, * ) ?

A. ( Z,* ) is a monoid
B. ( Z,* ) is an algebraic group
C. ( Z,* ) is a group
D. None of the mentioned
Answer» E.
10.

The most powerful parser is

A. SLR
B. LALR
C. Canonical LR
D. Operator Precedence
Answer» D. Operator Precedence
11.

LR parser are attractive because

A. It can be constructed to recognize CFG corresponding to almost all programming constructs
B. It does not backtrack
C. Both of the mentioned
D. None of the mentioned
Answer» D. None of the mentioned
12.

In operator precedence parsing whose precedence relations are defined

A. For all pair of non-terminals
B. For all pair of terminals
C. To delimit the handle
D. None of the mentioned
Answer» B. For all pair of terminals
13.

The symbol table implementation is based on the property of locality of reference is

A. Linear List
B. Search Tree
C. Hash table
D. Self Organization
Answer» D. Self Organization