Compiler MCQ with Answers Set-1

This post contains a computer network related to 20 multiple-choice questions (compiler SET-1) that help you to go through the subject and prepare you for compiler related questions in a competitive exam.

Compiler MCQ Test Series Set-1

  • Total Number of Questions: 20

  • Each question carries equal marks i.e 1

  • No Negative Marking

Page 1 of 2

1. Relocation bits used by relocating loader are specified (generated) by
A.
B.
C.
D.
E.
2. Which one of the following kinds of derivation is used by LR parsers?
A.
B.
C.
D.
3. Consider the following statements.

$S_1$: The sequence of procedure calls corresponds to a preorder traversal of the activation tree.

$S_2$: The sequence of procedure returns corresponds to a postorder traversal of the activation tree.

Which one of the following options is correct?
A.
B.
C.
D.
4. Consider the following statements.

$S_1$: Every SLR(1) grammar is unambiguous but there are certain ambiguous grammars that are not SLR(1).

$S_2$: For any context-free grammar, there is a parser that takes at a most time to parse a string of length n.

Which one of the following options is correct?
A.
B.
C.
D.
5. Consider the following statements.
  1. The symbol table is accessed only during analysis and syntax analysis.
  2. Compilers for programming languages that support recursion necessarily need heap storage for memory allocation in the run-time environment.
  3. Errors violating the condition ‘any variable must be declared before its use’ are detected during syntax analysis.
Which of the above statements is/are TRUE?
A.
B.
C.
D.
6.

Consider the following grammar (That admits a series of declarations, followed by expressions) and the associated syntax-directed translation (SDT) actions, given as pseudo-code:

$P\rightarrow D^{\ast} E^{\ast}$

$D\rightarrow$ int ID { record that ID. lexeme is of type int }

$D\rightarrow$ bool ID (record that ID. lexeme is of type bool}

$E\rightarrow E_1+E_2\left \{ check that E_1.type = E_2.type = int ; set E.type :=int \right \}$

$E\rightarrow !E_1\left \{ check that E_1.type = bool ; set E.type :=bool \right \}$

$E\rightarrow ID\left \{set E.type :=int \right \}$

With respect to the above grammar, which one of the following choices is correct?

 
A.
B.
C.
D.
7. Consider the following context-free grammar where the set of terminals is {a, b, c, d, f}.

$S\rightarrow daT|Rf$

$T\rightarrow aS|baT|\varepsilon$

$R\rightarrow caTR|\varepsilon$

The following is a partially-filled LL(1) parsing table.

 
abcdf$
S(1)$S\rightarrow daT$(2)
T$T\rightarrow aS$$T\rightarrow baT$(3)$T\rightarrow \varepsilon$(4)
R$R\rightarrow caTR$$R\rightarrow \varepsilon$
Which one of the following choices represents the correct combination for the numbered cells in the parsing table (“blank” denotes that the corresponding cell is empty)?
A.
B.
C.
D.
8. Cross-compiler is a compiler:
A.
B.
C.
D.
E.
9. Consider the following language.

L=\left \{ w \varepsilon{0, 1}^{*}|w ends with the substring 011 \right \}

Which one of the following deterministic finite automata accepts L?
A.
B.
C.
D.
10. 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 S
IN(S): the set of variables that are live at the entry of S
OUT(S): the set of variables that are live at the exit of S
Consider a basic block that consists of two statements, S_1 followed by S_2. Which one of the following statements is correct?
A.
B.
C.
D.

 

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments