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.

In the context of compilers, which of the following is/are NOT an intermediate representation of the source program?

A. Control Flow Graph (CFG)
B. Symbol table
C. Three address code
D. A bstract Syntax Tree (AST)
Answer» C. Three address code
2.

Match the following according to input (from the left column) to the compiler phase (in the right column) that processes it:(P)Syntax tree(i)Code generator(Q)Character steam(ii)Syntax analyzer(R)Intermediate representation(iii)Semantic analyser(S)Token stream(iv)Lexical analyzer

A. P → (ii), Q → (iii), R → (iv), S → (i)
B. P → (ii), Q → (i), R → (iii), S → (iv)
C. P → (iii), Q → (iv), R → (i), S → (ii)
D. P → (i), Q → (iv), R → (ii), S → (iii)
Answer» D. P → (i), Q → (iv), R → (ii), S → (iii)
3.

Consider the basic block given below.a = b + cc = a + dd = b + ce = d - ba = e + bThe minimum number of nodes and edges present in the DAG representation of the above basic block respectively are

A. 6 and 6
B. 8 and 10
C. 9 and 12
D. 4 and 4
Answer» B. 8 and 10
4.

Consider the intermediate code given below.1) i = 12) j = 13) t1 = 5 ∗ i4) t2 = t1 + j5) t3 = 4 ∗ t26) t4 = t37) a[t4] = - 18) j = j + 19) if j < = 5 goto (3)10) i = i + 111) if i < 5 goto (2)The number of nodes and edges in the control - flow - graph constructed for the above code, respectively, are

A. 5 and 7
B. 6 and 7
C. 5 and 5
D. 7 and 8
Answer» C. 5 and 5
5.

Generation of intermediate code based on an abstract machine model is useful in compilers because:

A. Syntax translations are easier for intermediate code generation
B. It is difficult to generate executable code from high level language program.
C. It enhances the portability of the compiler system program
D. It makes implementation of lexical and syntax analysis easier
Answer» D. It makes implementation of lexical and syntax analysis easier
6.

A variable x is said to be live at a statement Si in a program if the following three conditions hold simultaneously:i. There exists a statement Sj that uses xii. There is a path from Si to Sj in the flow graph corresponding to the programiii. The path has no intervening assignment to x including at Si and SjThe variables which are live both at the statement in basic block 2 and at the statement in basic block 3 of the above control flow graph are

A. p, s, u
B. r, s, u
C. r, u
D. q, v
Answer» D. q, v
7.

Consider the following intermediate program in three address code:p = a – bq = p * cp = u * vq = p + qWhich one of the following corresponds to a static single assignment form of the above code?

A. p1 = a - bq1 = p1 * cp1 = u * vq1 = p1 + q1
B. p3 = a – bq4 = p3 * cp4 = u * vq5 = p4 ­+ q4
C. p1 = a – bq1 = p2 * cp3 = u * vq2 = p4 + q3
D. p1 = a – bq1 = p * cp2 = u * vq2 = p + q
Answer» C. p1 = a – bq1 = p2 * cp3 = u * vq2 = p4 + q3
8.

Which of these does not belong to CFG?

A. Terminal Symbol
B. Non terminal Symbol
C. Start symbol
D. End Symbol
Answer» E.
9.

A CFG is closed under

A. Union
B. Kleene star
C. Concatenation
D. None of the mentioned
Answer» E.
10.

A regular Grammar is a

A. CFG
B. Non CFG
C. English Grammar
D. None of the mentioned
Answer» B. Non CFG
11.

Push down automata accepts which language

A. Context sensitive language
B. Context free language
C. Recursive language
D. None of the mentioned
Answer» C. Recursive language
12.

The context free grammar S ‚Üí SS | 0S1 | 1S0 | …õ generates$

A. Equal number of 0’s and 1’s
B. Unequal number of 0’s and 1’s
C. Number of 0’s followed by any number of 1’s
D. None of the mentioned
Answer» B. Unequal number of 0‚Äö√Ñ√∂‚àö√ë‚àö¬•s and 1‚Äö√Ñ√∂‚àö√ë‚àö¬•s
13.

The context free grammar S ‚Üí A111|S1, A ‚Üí A0 | 00 is equivalent to$

A. {0ⁿ1ᵐ | n=2, m=3}
B. {0ⁿ1ᵐ | n=1, m=5}
C. {0ⁿ1ᵐ | n should be greater than two and m should be greater than four}
D. None of these
Answer» B. {0‚Äö√Ñ√∂‚àö√ñ‚àö‚àè1¬¨‚à묨¬µ‚àö‚Ñ¢ | n=1, m=5}