Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests - Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests -

Compiler Design MCQs

Compiler design provides basic translation mechanism, error detection and recovery. It includes lexical, syntax, semantic analysis, code generation and optimization.

MCQs on Compiler Design

Solve Compiler Design Multiple-Choice Questions to prepare better for GATE. If you wish to learn more about Compiler Design and Compiler Design MCQs, you can check notes, mock tests, and previous years’ question papers. Gauge the pattern of MCQs on Compiler Design by solving the ones that we have compiled below for your practice:

Compiler Design Multiple-Choice Questions

1. In the compilers, the keywords of any language can be recognized during the:

a. code generation

b. program’s parsing

c. dataflow analysis

d. program’s lexical analysis

Answer: (d) program’s lexical analysis

2. Which of these is a top-down parser?

a. An LALR(k) parser

b. An LR(k) parser

c. Operator precedence parser

d. Recursive descent parser

Answer: (d) Recursive descent parser

3. Look at the grammar A → AA | (A) | ε

It is not suitable for the process of predictive-parsing since the grammar is:

a. an operator-grammar

b. right-recursive

c. left-recursive

d. ambiguous

Answer: (c) left-recursive

4. Which grammar rule violates an operator grammar’s requirements? Here, P, Q, R are nonterminals, while r, s, t are terminals.

I. P → Q R

II. P → Q s R

III. P → ε

IV. P → Q t R r

a. I only

b. I and III only

c. II and III only

d. III and IV only

Answer: (b) I and III only

5. In the case of a bottom-up evaluation of a definition that is syntax-directed, the inherited attributes can:

a. never be evaluated

b. only be evaluated when the definition consists of synthesized attributes

c. only be evaluated when the definition is L-­attributed

d. always be evaluated

Answer: (c) only be evaluated when the definition is L-­attributed

6. Which derivation uses a top-down parser while parsing some input strings? Assume that the input is scanned in the order of left to right.

a. The rightmost derivation that is traced out in reverse

b. The rightmost derivation

c. The leftmost derivation that is traced out in reverse

d. The leftmost derivation

Answer: (d) The leftmost derivation

7. Choose the statement that is false.

a. The unambiguous grammars have the same rightmost and leftmost derivation

b. The LL(1) parsers are top-down parsers

c. The LALR is comparatively more powerful than the SLR

d. The ambiguous grammars can never be LR(k) for a k

Answer: (a) The unambiguous grammars have the same rightmost and leftmost derivation

8. Consider a certain program X consisting of two source modules A1 and A2 that are contained in two separate files. In case A1 consists of a reference to the function that is defined in A2, then the reference will be resolved during the:

a. Compile-time

b. Edit-time

c. Load-time

d. Link-time

Answer: (d) Link-time

9. A lexical analyzer’s output is:

a. Intermediate code

b. A parse tree

c. A stream of tokens

d. Machine code

Answer: (c) A stream of tokens

10. The total number of tokens that are present in the following statement in C is:

printf(“i=%d, &i=%x”, i&i);

a. 6

b. 10

c. 9

d. 13

Answer: (c) 9

11. In case we detect an error within a statement, then the type that is assigned to this statement is:

a. Type error

b. Error type

c. Type expression

d. Type constructor

Answer: (a) Type error

12. What technique do we use for the process of parameter passing in an in-line expansion?

a. Call-by name

b. Call-by address

c. Call-by reference

d. Call-by value

Answer: (a) Call-by name

13. The access time is the minimum to access the symbol table that makes use of:

a. Linear

b. Self-organizing list

c. Search tree

d. Hash table

Answer: (d) Hash table

14. The technique of live variable analysis is used for:

a. Type checking

b. Code generation

c. Code optimization

d. Parsing

Answer: (c) Code optimization

15. What would be the E val for the string 1 * 0?

a. 4

b. 8

c. 12

d. 6

Answer: (a) 4

16. Look at the following code segment:

x = u – t;

y = x * v;

x = y + w;

y = t – z;

y = x * y;

What would be the minimum number of variables required for the conversion of this code segment to the static single assignment form?

a. 10

b. 9

c. 8

d. 6

Answer: (a) 10

17. The maximum reduce moves that a bottom-up parser can take for grammar without epsilon and the unit-production (of type A -> є as well as A -> a) for parsing the strings with n tokens would be:

a. 2^n

b. 2n-1

c. n-1

d. n/2

Answer: (c) n-1

18. The total number of bits that are present are in the “tag” that is filed in the cache are:

a. 5

b. 6

c. 7

d. 8

Answer: (b) 6

19. Consider the following grammar expression:

E -> E * F | F + E | F

F -> F – F | id

Choose the statement that is true.

a. The precedence of * is higher as compared to +

b. The precedence of – is higher as compared to *

c. + and — have the very same precedence

d. The precedence of + is higher as compared to *

Answer: (b) The precedence of – is higher as compared to *

20. The lexical analysis of various modern computer languages like Java requires the power of which of these machine models in a sufficient and necessary sense?

a. Turing Machine

b. Pushdown Automata (Non-Deterministic)

c. Pushdown Automata (Deterministic)

d. Finite State Automata

Answer: (d) Finite State Automata

Keep learning and stay tuned to get the latest updates on the GATE Exam along with GATE MCQs, GATE Eligibility Criteria, GATE Syllabus for CSE (Computer Science Engineering), GATE Notes for CSE, GATE CSE Question Paper, and more.

Comments

Leave a Comment

Your Mobile number and Email id will not be published.

*

*