0% found this document useful (0 votes)
444 views48 pages

MCQ

Uploaded by

dine62611
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
444 views48 pages

MCQ

Uploaded by

dine62611
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 48

1. What is a compiler?

a) system program that converts instructions to machine language


b) system program that converts machine language to high-level language
c) system program that writes instructions to perform
d) None of the mentioned
View Answer
Answer: a
Explanation: A compiler is a system program that converts instructions in form of
code to machine understandable language.

2. Which of the following is a stage of compiler design?


a) Semantic analysis
b) Intermediate code generator
c) Code generator
d) All of the mentioned
View Answer
Answer: d
Explanation: The phases of a compiler are:
1. Lexical analysis
2. Syntax analysis
3. Semantic analysis
4. Intermediate code generator
5. Code optimizer
6. Code generator

3. What is the use of a symbol table in compiler design?


a) Finding name’s scope
b) Type checking
c) Keeping all of the names of all entities in one place
d) All of the mentioned
View Answer
Answer: d
Explanation: Both the analysis and synthesis components of a compiler use the
symbol table.
i) To keep all of the names of all entities in one place in a systematic format.
ii) To determine whether or not a variable has been declared.
iii) Type checking is implemented by ensuring that assignments and expressions in
source code are semantically accurate.
iv) To figure out what a name’s scope is (scope resolution).

4. Which of the following error can a compiler check?


a) Syntax Error
b) Logical Error
c) Both Logical and Syntax Error
d) Compiler cannot check errors
View Answer
Answer: a
Explanation: Logic flaws can never be checked by a compiler.

5. A programmer, writes a program to multiply two numbers instead of dividing


them by mistake, how can this error be detected?
a) Compiler or interpreter
b) Compiler only
c) Interpreter only
d) None of the mentioned
View Answer
Answer: d
Explanation: This is a logical error that can’t be detected by any compiler or
interpreter.
advertisement
6. Who is responsible for the creation of the symbol table?
a) Assembler
b) Compiler
c) Interpreter
d) All of the mentioned
View Answer
Answer: b
Explanation: The compiler generates a symbol table, which contains a list of lexemes
or tokens.

7. Which of the following is known as a compiler for a high-level language that runs
on one machine and produces code for a different machine?
a) Cross compiler
b) Multipass compiler
c) Optimizing compiler
d) One pass compiler
View Answer
Answer: a
Explanation: So done by the definition.

8. Which of the following is a system program that integrates a program’s


individually compiled modules into a form that can be executed?
a) Interpreter
b) Assembler
c) Compiler
d) Linking Loader
View Answer
Answer: d
Explanation: A loader that combines the functionality of a relocation loader with the
ability to combine a number of independently compiled program segments.

9. Which of the following is a definition of compiler?


a) Acceptance of a program written in a high-level language and produces an object
program
b) Program is put into memory and executes it
c) Translation of assembly language into machine language
d) None of the mentioned
View Answer
Answer: a
Explanation: A compiler is a software (or combination of programs) that converts
source code written in one programming language (the source language) into code
written in another programming language (the target language) (the target
language, often having a binary form known as object code).

10. Which of the following phase of the compiler is Syntax Analysis?


a) Second
b) Third
c) First
d) All of the mentioned
View Answer
Answer: a
Explanation: It is the Second Phase of the Compiler after Lexical Analyzer. It is also
called Hierarchical Analysis or Parsing.

11. Which of the following concept of FSA is used in the compiler?


a) Code optimization
b) Code generation
c) Lexical analysis
d) Parser
View Answer
Answer: c
Explanation: Because the lexer performs its analysis by going from one stage to
another.

12. Which of the following is a part of a compiler that takes as input a stream of
characters and produces as output a stream of words along with their associated
syntactic categories?
a) Optimizer
b) Scanner
c) Parser
d) None of the mentioned
View Answer
Answer: b
Explanation: A compiler’s scanner scans a character-based input stream and creates
a word-based output stream, with each word identified with its Syntactic category.

13. Let L1 = {w ∈ {0,1}∗ | w has at least as many occurrences


of (110)’s as (011)’s}.
Let L2 = { ∈ {0,1}∗ | w has at least as many occurrences
of (000)’s as (111)’s}.
Which of the following is correct?
a) L2 is regular
b) L1 and L2 are regular
c) L1 is regular but not L2
d) None of them are regular
View Answer
Answer: c
Explanation: Let’s look at the string 011011011011 to see if L1 is regular. The
number of times 011 has occurred is four, however, it has also occurred three
times. We can also produce a 110 if the string ends with 011. The following string is
110110110110, where 110 appears four times and 011 appears three times, already
satisfying the.

14. What is CFG?


a) Regular Expression
b) Compiler
c) Language expression
d) All of the mentioned
View Answer
Answer: b
Explanation: They’re defined by the rule A->b, where A isn’t terminal and b is.

15. Which of the following is a correct statement?


I. For some programming languages, there are parsing algorithms with an O(3)
complexity.
II. A recursive programming language can be constructed with static storage
allocation.
III. In the context of bottom-up parsing, no L-attributed definition can be evaluated.
IV. Code-improvement modifications can be carried out at both the intermediate
and source code levels.
a) I and III
b) I and IV
c) I, II and IV
d) I, II, III and IV
View Answer
Answer: b
Explanation: In recursion, space is used but recursive calls can’t be calculated by the
compiler.

16. Which of the following is correct regarding an optimizer Compiler?


a) Optimize the code
b) Is optimized to occupy less space
c) Both of the mentioned
d) None of the mentioned
View Answer
Answer: d
Explanation: An optimising compiler is a computer programme that strives to
minimise or maximise specific characteristics of an executable programme.

17. Which of the following error can Compiler diagnose?


a) Logical errors only
b) Grammatical and logical errors
c) Grammatical errors only
d) All of the mentioned
View Answer
Answer: c
Explanation: Only syntactical errors can be detected by the compiler.

18. In which of the following phase of the compiler is Lexical Analyser?


a) Second
b) Third
c) First
d) All of the mentioned
View Answer
19. Which of the following does an address code involve?
a) No unary operators
b) Exactly 3 address
c) At most Three address
d) None of the mentioned
View Answer
Answer: d
Explanation: In computer science, three-address is an intermediate code used by
optimizing compilers to aid in the implementation of code-improving
transformations.

20. An object module for a group of programs that were compiled separately is
handed to a linker. Which of the following about an object module isn’t true?
a) Relocation bits
b) Names and locations of all external symbols denied in the object module
c) Absolute addresses of internal symbols
d) Object code
View Answer
Answer: c
Explanation: A linker, sometimes known as a link editor, is a computer program that
merges one or more object files generated by a compiler into a single executable,
library, or another object file.

21. Characters are grouped into tokens in which of the following phase of the
compiler design?
a) Code generator
b) Lexical analyzer
c) Parser
d) Code optimization
View Answer
22. Why Generation of intermediate code based on an abstract machine model is
useful in compilers?
a) Writing for intermediate code generation
b) Portability of the front end of the compiler
c) Implementation of lexical analysis and syntax analysis is made easier
d) All of the mentioned
View Answer
Answer: c
Explanation: Intermediate code generator receives input from its predecessor
phase, semantic analyzer, in the form of an annotated syntax tree.

23. Why System program such as compiler are designed?


a) They are Serially usable
b) They are Re-enterable
c) They are Nonreusable
d) All of the mentioned
View Answer
Answer: b
Explanation: Re-enterable is the keyword for compiler being designed.

24. Which of the following technique is used for building cross compilers for other
machines?
a) Canadian Cross
b) Mexican Cross
c) X-cross
d) Brazilian Cross
View Answer
Answer: a
Explanation: The Canadian Cross is a technique for building cross compilers for
other machines. Given three machines X, Y, and Z, one uses machine X (e.g. running
Windows XP on an IA-32 processor) to build a cross compiler that runs on machine Y
(e.g. running Mac OS X on an x86-64 processor) to create executables for machine Z.

25. Which of the following can detect an error if a programmer by mistake writes
multiplication instead of division?
a) Interpreter
b) Compiler or interpreter test
c) Compiler
d) None of the mentioned
View Answer
Answer: d
Explanation: No Logical errors can’t be detected.

ompiler Design MCQs


The following Compiler Design MCQs have been compiled by our experts through research,
in order to test your knowledge of the subject of Compiler Design. We encourage you to
answer these 40 multiple-choice questions to assess your proficiency.
Please continue by scrolling down.

1: Which of the following is NOT a characteristic of a


greedy algorithm?
A. A greedy algorithm always gives an optimal problem solution.

B. A greedy algorithm can be recursive.

C. A greedy algorithm can be iterative.

D. A greedy algorithm can be used with graph data structures.

Hide

2: Which of the following algorithms is NOT related to a


graph mining?
A. Breadth-first search algorithm

B. Fast Fourier transform algorithm

C. Dijkstra's algorithm

D. Prim's algorithm

Hide
3: Is it possible to multiply two matrices with dimensions
4*6 for the first matrix and 8*10 for the second matrix?
A. It is always possible.

B. It is always impossible.

C. It is possible only in complex analysis but not in real domain.

D. It is possible only the determinant of first matrix is non-zero.

Hide

4: Is garbage collection available in Common Lisp


implementations?
A. No, it isn't.

B. Yes, but only in SBCL.

C. Yes, in all implementations.

D. Yes, except in CMUCL.

Hide

5: What is the return value of the subtype "predicate", in


case it CANNOT decide what is the relation between
types it is asked about?
A. It will raise an exception

B. It will return nil

C. It will return (nil nil)

D. It will return (nil nil t)

Hide

6: Which of the following problems prevents garbage


collectors from being used in the real-time systems?
A. They involve huge memory fragmentation.
B. They can not be thread-safe.

C. They can make real-time systems hang for some period of time.

D. All of the above

Hide

7: What is the advantage of using a suballocator in a


memory management system?
A. It allows to have memory chunks of any size

B. It obtains large blocks of memory from the system memory manager and allocates the
memory to the application in smaller pieces.

C. It hides memory leaks from the operating system

D. All of the above answers are correct

Hide

8: What is the difference between eq and eql type


predicates in Common Lisp?
A. There are no such type predicates, so the question is incorrect

B. eq is true only when tested object are the same identical object and eql is true only when
tested objects have the same type and value

C. eql is true only when tested objects are the same identical object and eq is true only when
tested objects have the same type and value

D. eq is a function, whereas eql is a macro.

Hide

9: What is amortized analysis is used for?


A. To prove the stability of an algorithm.

B. To analyze an algorithm behavior on random input data

C. To find out the average algorithm performance in worst case

D. None of the above


Hide

10: What is a bytecode interpreter?


A. A program for the vulnerability analysis of a bytecode.

B. A program for automatic translation of a bytecode from Unicode to UTF-8.

C. A program which executes bytecode instructions.

D. All of the above.

Hide

11: What is a generated code optimization method which


is NOT suitable for use in a compiler?
A. Code branching prediction

B. Constants folding and propagation

C. Loop invariant relocation outside

D. Common subexpressions elimination in a code blocks

Hide

12: Which of the following sorting algorithms has


average speed estimation defined as : O(n)?
A. Counting sort

B. Bucket sort

C. Radix sort

D. All of the above

Hide

13: What is the difference between a general binary


search tree and an optimal binary search tree?
A. An optimal binary search tree can be used only with unique nodes values
B. An optimal binary search tree has less average expected search time as compared with a
general binary search tree's one.

C. An optimal binary search tree can not be used for solving optimization problems.

D. All of the above

Hide

14: What is a heapsort?


A. A phase in incremental garbage collection.

B. A phase in generational garbage collection.

C. A fast and memory-effective sorting algorithm.

D. None of the above

Hide

15: What is an NP-complete problem?


A. A problem which can not be solved using a Turing machine

B. A problem which cannot be solved quickly.

C. A problem which can not be solved without involving neural networks involvement

D. None of the above

Hide

16: What is the difference between a Static Single


Assignments graph (SSAG) and a Control Flow Graph
(CFG) which are used for the intermediate compiled
sources representation in a compiler?
A. An SSAG is more suitable for a code optimization than a CFG.

B. All SSAG graph elements have unique names but CFG ones do not.

C. SSAG graph construction is much more complicated than CFG construction.

D. All of the above.


Hide

17: Which of the following is NOT a standard Common


Lisp type testing predicate?
A. standard-string-p

B. standard-char-p

C. simple-bit-vector-p

D. random-state-p

Hide

18: Which of the following is NOT a valid Common Lisp


symbol name?
A. ||||

B. <><><>M<

C. ?/?

D. #?#

Hide

19: Which among the following is NOT a common


element of parser internals?
A. Finite state machine

B. Indefinite state machine

C. Petri net

D. Language grammar rules interpreter

Hide

20: What branching instructions type is more resource-


consuming on the RISC processor?
A. Long branch instruction
B. Short branch instruction

C. All instructions are equal in CPU resources consumption

D. RISC processor typically has only long branch instruction. The question therefore is
incorrect

Hide

21: What functionality of the listed below is NOT


common to a parser?
A. Syntax errors handling in a program sources

B. Semantic errors handling in a program sources

C. Converting a program sources to a syntax tree

D. Applying a language grammar rules to a program sources

Hide

22: What is the relationship between lexical and syntax


analysis?
A. They are one and the same thing.

B. Lexical analysis includes syntax analysis.

C. Syntax analysis includes lexical analysis

D. They have no relationship with each other.

Hide

23: Which of the following options is NOT a technique


used in "peephole optimization" of the generated code in
a compiler?
A. Sequential load and store instructions elimination

B. Identifying patterns in the instruction stream which are known to be performance gaps

C. Constants folding in the memory addresses used by the generated instructions


D. Optimization of the generated code by performing branching analysis algorithms which
take target machine characteristics into account

Hide

24: Assume that two instructions L1 and L2 are


dependent in a flow graph. What does it mean when one
says that they are output-dependent?
A. They map to the same instruction position in the generated code

B. They produce the same result when called

C. They write to the same memory location when called

D. They share the same output stream block in a code generation phase

Hide

25: What is the optimal way of copying the contents of


one array to another in C language?
A. By using the memcpy function.

B. By using a loop.

C. By using a SSE3 instructions for fast memory chunks movement.

D. All of the above approaches are equivalent

Hide

26: What is the main advantage of using segregated lists


usage in the manual memory management?
A. They keep track of memory leaks in an application

B. They allow to allocate memory chunks of any required size

C. Memory management systems based on segregated lists are extremely fast

D. All of the above

Hide
27: Which among the following is NOT a standard
Common Lisp stream?
A. *query-io*

B. *terminal-input*

C. *trace-output*

D. *debug-io*

Hide
28:

What does the following Common Lisp line describes?

(vector 'integer 1234567890)

A.

This is a vector of integer type whose absolute value can not be more than 1234567890

B.

This is a vector of integers and its tag index is 1234567890

C.

This is a vector of integers and its length is 1234567890

D.

This type definition is incorrect

Hide

29: Which of the following is a dispatch macro character


in Common Lisp?
A. `

B. ,

C. %
D. #

Hide

30: What is the fastest way to establish a relationship


between two objects?
A. By using a hash map.

B. By using a B-tree.

C. By using a binary search tree.

D. All of the above

Hide

31: What does it mean if when an algorithm "A", belongs


to the O(n) algorithms:
A. That algorithm

B. That algorithm

C. That algorithm

D. None of the above

Hide

32: Which of the following is NOT a garbage collection


algorithm?
A. Train algorithm

B. Baker algorithm

C. Cheney algorithm

D. Car algorithm

Hide

33: Is it possible to prove the theoretical stability (that is,


prove that a collection algorithm will work as expected)
of a garbage collector used in conjunction with C
language?
A. Yes, and in case of all garbage collector types.

B. Yes, but only in the case of a generational garbage collector.

C. Yes, but only in the case of an incremental garbage collector.

D. It is not possible to prove the theoretical stability of any garbage collector type.

Hide
34: When using 'optional' keyword for declaring a lambda, such as 'optional (x y z)', what
does x, y and z signify?
A. They are all optional variables names

B. x is a variable name, y is a binding flag and z is the default value for the variable x

C. y is a variable name, x is a binding flag and z is the default value for the variable y

D. x is a variable name, z is a binding flag and y is the default value for the variable x

Hide

35: Which of the following is NOT a garbage collection


technique?
A. Simple reference counting

B. Deferred reference counting

C. 1-bit reference counting

D. Composed reference counting

Hide

36: What is the main disadvantage of the bitmapped


memory allocation scheme of the manual memory
management?
A. Bitmapped memory allocation scheme belongs to automated memory management
methods, so question is incorrect.
B. It is extremely hard to code on C and requires a great debugging effort before it starts
working.

C. Iit causes huge and frequent memory fragmentations.

D. It allocates memory too slow.

Hide

37: When does a memory leak happen?


A. It happens when a object created, is not destroyed.

B. It happens when memory is still marked as used even after the object has been deleted.

C. It happens when two objects hold references to each other and thus they cannot be
deleted.

D. All of the above

Hide

38: Which data structure does a compiler use to solve the


register allocation problem?
A. registers relation map

B. registers interference graph

C. registers dependency list

D. registers allocation tree

Hide

39: What is the most important problem of the a


conservative garbage collector?
A. It has risk of misidentifying an application data as a heap pointer

B. It tends to have memory leaks in its own implementation

C. It is not suitable for use with low-level (such as C) languages

D. It is the slowest type of garbage collectors

Hide
40: Which of the following is NOT a Common Lisp
equality test predicate?
A. e

B. eq

C. eql

D. equal

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

Compiler Design MCQ


1) Users write the programs in which language?

a. Low-level Language
b. High-Level Language
c. Decimal-Format
d. Middle-Level Language

Hide Answer Workspace

Answer: b. High-Level Language

Explanation: Users write the program in a high-level language because it is easier to


use, understand and remember.

2) Which computer program accepts the high-level language and converts it into
assembly language?

a. Interpreter
b. Linker
c. Assembler
d. Compiler

Hide Answer Workspace


Answer: d. Compiler

Explanation: Compiler is a computer program that accepts the code written in a


high-level language and converts that code into the assembly language.

3) Does the compiler program translate the whole source code in one step?

a. No
b. Depends on the Compiler
c. Don't Know
d. Yes

Hide Answer Workspace

Answer: d. Yes

Explanation: The compiler is that program which translates the whole high-level
code into the machine code at once.

4) Which of the following file is an output of the assembler?

a. Program file
b. Object file
c. Data File
d. Task File

Hide Answer Workspace

Answer: b. Object File

Explanation: The object file contains the object code, which is an output of an
assembler.

5) Which tool is used for grouping of characters in tokens in the compiler?

a. Parser
b. Code optimizer
c. Code generator
d. Scanner

Hide Answer Workspace

Answer: d. Scanner

Explanation: Scanner is a subroutine which is called by the compiler program. The


scanner combines the characters and implements them to produce tokens.

6) What is the linker?

a. It is always used before the program execution.


b. It is required to create the load module.
c. It is the same as the loader
d. None of the above

Hide Answer Workspace

Answer: b. It is required to create the load module.

Explanation: Linker is a program in the compiler which is required to create a load


module.

7) Parsing is categorized into how many types?

a. three types
b. four types
c. two types
d. five types

Hide Answer Workspace

Answer: c. two types

Explanation: In the compiler design, the parser is mainly categorized into top-down
parsing and bottom-up parsing.
8) In which parsing, the parser constructs the parse tree from the start symbol and
transforms it into the input symbol.

a. Bottom-up parsing
b. Top-down parsing
c. None of the above
d. Both a and b

Hide Answer Workspace

Answer: b. Top-Down Parsing

Explanation: Top-down parsing is a technique which constructs the parse tree from
the start symbol and transforms it to the input symbol. This type of parsing is also
referred to as predictive or recursive parsing.

9) Which derivation is generated by the top-down parser?

a. Right-most derivation in reverse


b. Left-most derivation in reverse
c. Right-most derivation
d. Left-most derivation

Hide Answer Workspace

Answer: d. Left-most derivation

Explanation: Top-down parser generates the left-most derivation. It constructs the


parse tree from left to right and constructs the left-most derivation of the specified
sentence.

10) Which derivation is generated by the bottom-up parser?

a. Right-most derivation in reverse


b. Left-most derivation in reverse
c. Right-most derivation
d. Left-most derivation
Hide Answer Workspace

Answer: a. Right-most derivation in reverse.

Explanation: Bottom-up parser generates the right-most derivation in reverse. It


constructs the parse tree from the input string to the root and tries to construct the
right-most derivation of the specified string backward.

11) Which parser is most powerful in the following parsers?

a. Operator Precedence
b. SLR
c. Canonical LR
d. LALR

Hide Answer Workspace

Answer: c. Canonical LR

Explanation: Canonical LR (CLR) is the most powerful parser than LALR and SLR.

12) The output of the lexical analyzer is _______

a. string character
b. a syntax tree
c. a set of RE
d. a set of tokens

Hide Answer Workspace

Answer: d. a set of tokens

Explanation: Lexical analyzer gives the set of tokens as output. The set of tokens
contains keywords, separators, literals, identifiers, and operators.

13) From the following grammars, which describes the lexical syntax?
a. Lexical Grammar
b. Context-free Grammar
c. Syntactic Grammar
d. Regular Grammar

Hide Answer Workspace

Answer: a. Lexical Grammar

Explanation: Lexical grammar is a type of grammar which specifies the syntax of


tokens.

14) Which grammar gives multiple parse trees for the same string?

a. Unambiguous
b. Regular
c. Ambiguous
d. All of the above

Hide Answer Workspace

Answer: c. Ambiguous

Explanation: Ambiguous grammar is a context-free grammar which gives more than


one leftmost or rightmost derivation for the same specified sentence.

15) In Compiler lexical analyzer is used for?

a. removing comments
b. removing whitespace
c. breaking the syntaxes in the set of tokens
d. All of the mentioned

Hide Answer Workspace

Answer: d. All of the mentioned


Explanation: Lexical analyzer is used in the compiler for removing the Whitespace
and comments. It is also used in breaking the syntaxes into the set of tokens.

16) Which is considered as the sequence of characters in a token?

a. Mexeme
b. Lexeme
c. Texeme
d. Pattern

Hide Answer Workspace

Answer: b. Lexeme

Explanation: Lexemes are the string of alphanumeric characters in a single token. In


the source program, lexemes are characters which are identified by the pattern for a
token.

17) Which part of the compiler highly used the grammar concept?

a. Code optimization
b. Code generation
c. Parser
d. Lexical Analysis

Hide Answer Workspace

Answer: c. Parser

Explanation: The concept of grammar is much used in the parser phase of the
compiler.

The parser phase is next to the lexical analysis phase in the compiler. Parser
generated the parse tree using the predefined grammar. The parser has two different
techniques for creating a different parse tree.

18) Which phase of the compiler checks the grammar of the programming?
a. Code Optimization
b. Semantic Analysis
c. Code Generation
d. Syntax Analysis

Hide Answer Workspace

Answer: d. Syntax Analysis

Explanation: Syntax Analysis is the 2nd phase of the compiler, which checks the
given input string is the correct syntax of the programming language.

19) Which of the following component is important for semantic analysis?

a. Yacc
b. Lex
c. Symbol Table
d. Type Checking

Hide Answer Workspace

Answer: d. Type checking

Explanation: In the semantic analysis, type checking is an important component


because it verifies the program's operations from the semantic conventions.

20) Which phase of the compiler is also known as Scanner?

a. Syntax Analysis
b. Lexical Analysis
c. Semantic Analysis
d. Code generation

Hide Answer Workspace

Answer: b. Lexical Analysis


Explanation: The first part of the compiler (lexical analysis) is also known as a
scanner. It scans the characters from the source program and implements them to
produce tokens.

21) Which phase of the compiler is also known as Parser?

a. Code Optimization
b. Semantic Analysis
c. Syntax Analysis
d. Lexical Analysis

Hide Answer Workspace

Answer: c. Syntax Analysis

Explanation: The phase of the compiler next to the lexical analysis phase is also
known as Parser.

Syntax analysis or parser accepts the tokens produced by the lexical analysis and
gives the parse tree in the output.

22) Which of the following parser is a top-down parser?

a. An LALR parser
b. A LR parser
c. Operator precedence parser
d. Recursive descent parser

Hide Answer Workspace

Answer: d. Recursive descent parser

Explanation: Recursive descent parser is a type of top-down parser which generates


the parse tree from top to bottom and reads the input string from left to right.

23) Keywords are recognized in a compiler during -


a. the code generation
b. the data flow analysis
c. the lexical analysis of the program
d. the program parsing

Hide Answer Workspace

Answer: c. the lexical analysis of the program

Explanation: Keywords are firstly recognized during the lexical analysis of the
program in the compiler.

24) Leaf nodes in a parse tree indicate?

a. sub-terminals
b. half-terminals
c. non-terminals
d. terminals

Hide Answer Workspace

Answer: d. terminals.

Explanation: All the leaf nodes in the parse tree indicate the terminals. And all the
interior nodes indicate non-terminals.

25) Which graph describes the basic block and successor relationship?

a. Control graph
b. DAG
c. Flow graph
d. Hamilton graph

Hide Answer Workspace

Answer: c. Flow graph


Explanation: A flow graph is a graph of the compiler which describes the basic
blocks and how the program control is passed between the blocks.

26) Which language is accepted by the push-down automata?

a. Type 0 language
b. Type 1 language
c. Type 2 language
d. Type 3 language

Hide Answer Workspace

Answer: c. Type 2 language

Explanation: According to the Chomsky hierarchy, push down automata accepts the
Type 2 language, which is used for context-free language.

27) The most general phase of structured grammar is?

a. Context-sensitive grammar
b. Context-free grammar
c. Regular grammar
d. All of these

Hide Answer Workspace

Answer: a. Context Sensitive Grammar

Explanation: Context-sensitive grammar is the most general phase of structured


grammar because, in this grammar, the left-hand side and the right side contain the
terminals or non-terminals.

28) In the compiler, the function of using intermediate code is:

a. to improve the register allocation


b. to increase the error reporting & recovery.
c. to make semantic analysis easier.
d. to increase the chances of re-using the machine-independent code optimizer in other
compilers.

Hide Answer Workspace

Answer: d. to increase the chances of re-using the machine-independent code


optimizer in other compilers.

Explanation: After semantic analysis, the intermediate code increases the chances of
reusing the machine-independent code optimizer in other compilers.

29) In how many types of optimization can be divided?

a. two types
b. three types
c. four types
d. five types

Hide Answer Workspace

Answer: a. two types

Explanation: The code optimization technique is divided into machine-dependent


and machine-independent types.

30) The value of which variable is updated inside the loop by a loop-invariant value?

a. loop
b. strength
c. induction
d. invariable

Hide Answer Workspace

Answer: c. induction
Explanation: The value of the induction variable is updated inside the loop by a
loop-invariant value.

31) Which compiler runs on one machine and generates code for multiple machines?

a. Multipass compiler
b. Cross compiler
c. Optimizing compiler
d. Onepass compiler

Hide Answer Workspace

Answer: b. Cross compiler

Explanation: Cross compiler is a compiler which runs on one machine and generates
code for more than one machine.

32) Which of the following is not a characteristic of the compiler?

a. More execution time


b. Debugging process is slow
c. The execution takes place after the removal of all syntax errors
d. Firstly scans the entire program and then transforms it into machine-understandable
code

Hide Answer Workspace

Answer: a. More execution time

Explanation: The compiler does not take more time to execute. So, more execution
time is not a characteristic of the compiler.

33) Which phenomenon happens when the non-terminal on the left side is repeated as
the first symbol on the right side?

a. Left-most derivation
b. Left recursion
c. Left factoring
d. Left parsing

Hide Answer Workspace

Answer: b. Left recursion

Explanation: Left recursion is the process in which non-terminal on the left side of
the production is the same on the right side as the leftmost symbol.

34) In which derivation the right-most non-terminal symbol is replaced at each step?

a. Right look ahead


b. Right claim
c. Rightmost
d. Right non-terminal

Hide Answer Workspace

Answer: c. Rightmost

Explanation: The rightmost derivation is that derivation of context-free grammar,


which replaces the rightmost non-terminal symbol at each step.

35) In which derivation the leftmost non-terminal symbol is replaced at each step?

a. Left recursion
b. Left non-terminal
c. Left pushdown
d. Leftmost

Hide Answer Workspace

Answer: d. Leftmost

Explanation: The leftmost derivation is that derivation of context-free grammar


which replaces the leftmost non-terminal symbol at each step.
36) The compiler can detect what type of errors?

a. neither logical nor grammatical error


b. logical errors only
c. grammatical errors only
d. both grammatical and logical errors

Hide Answer Workspace

Answer: c. grammatical errors only.

Explanation: Compiler is a computer program that detects grammatical errors, not


logical errors.

37) Which symbol is not related to context-free grammar?

a. End symbol
b. Start symbol
c. Non-terminal symbol
d. Terminal symbol

Hide Answer Workspace

Answer: a. End symbol

Explanation: Context-free grammar is that grammar which consists of the start


symbol, set of terminals, set of non-terminal symbols and the set of productions.

38) Which method merges the multiple loops into the single one?

a. Constant Folding
b. Loop rolling
c. Loop fusion or jamming
d. None of the above

Hide Answer Workspace


Answer: c. Loop fusion or Loop jamming

Explanation: Loop fusion is an optimization technique which merges the multiple


bodies of loops into a single body. This programming technique may reduce the
runtime performance of the program.

39) Which parser is known as the shift-reduce parser?

a. Bottom-up parser
b. Top-down parser
c. Both Top-down and bottom-up
d. None of the Above

Hide Answer Workspace

Answer: a. Bottom-up parser

Explanation: Bottom-up parser in the compiler is also called the shift-reduce parser.

40) Which of the following tree is the pictorial identification of the derivation?

a. The oct tree


b. The parse tree
c. The binary tree
d. None of the above

Hide Answer Workspace

Answer: b. The parse tree

Explanation: The tree which represents the syntactic structure of the string is known
as the parse tree. It also indicates the terminal, start symbol, and non-terminal
symbols.

41) The full form of YACC is:

a. Yet Another Computer Computer


b. Yet Another Computer Compiler
c. Yet Another Compiler Computer
d. Yet Another Compiler Compiler

Hide Answer Workspace

Answer: d. Yet Another Compiler Compiler

Explanation: The full form of YACC is Yet Another Compiler Compiler, which
produces the LALR (1) grammar parser.

42) What type of conflicts can occur in the shift-reduce parsing?

a. reduce/reduce
b. shift/reduce
c. Both shift/reduce and reduce/reduce
d. None of the above

Hide Answer Workspace

Answer: b. Shift/reduce

Explanation: None

43) Which of the following grammar can be translated into DFAs?

a. Generic Grammar
b. Left Linear Grammar
c. Right Liner Grammar
d. All of the above

Hide Answer Workspace

Answer: c. Right Linear Grammar

Explanation: A right linear grammar is that grammar which contains all the non-
terminals on the right-hand side at the right ends. This grammar can be simply
converted into the DFA.
44) Which algorithm invokes a function GETREG()?

a. Code motion algorithm


b. Code optimization algorithm
c. Intermediate Code
d. Code generation algorithm

Hide Answer Workspace

Answer: d. Code generation algorithm

Explanation: Code generation algorithm invokes the GETREG() function to check the
status of available registers and the location where the result should be stored. This
function also selects the registers for every memory location.

45) FORTRAN programming language is a _______

a. Turing language
b. Context-sensitive language
c. Context-free language
d. Regular language

Hide Answer Workspace

Answer: b. Context-sensitive language.

Explanation: Context-sensitive languages are those languages which are defined by


context-sensitive grammar.

46) The execution time of the code depends on?

a. the usage of machine idioms


b. the way the registers are used
c. the orders in which the computations are performed
d. All of the mentioned
Hide Answer Workspace

Answer: d. All of the mentioned

Explanation: None

47) Which optimization technique is used to reduce the multiple jumps?

a. Latter optimization technique


b. Peephole optimization technique
c. Local optimization technique
d. Code optimization technique

Show Answer Workspace

48) Which of the following term is used to keep track of the location where the current
values of the name are stored?

a. Register descriptor
b. Address descriptor
c. Allocation descriptor
d. Flag register

Hide Answer Workspace

Answer: b. Address descriptor

Explanation: The address descriptor is a descriptor of the code generator technique,


which keeps track of the memory location.

49) Which of the following are labeled by operator symbol?

a. Root
b. Interior nodes
c. Leaves
d. Nodes
Hide Answer Workspace

Answer: b. Interior nodes

Explanation: In the compiler, interior nodes are specified by the operator symbol.

50) DAG is an abbreviation of?

a. Detecting Acyclic Graph


b. Data Acyclic Graph
c. Dynamic Acyclic Graph
d. Directed Acyclic Graph

Hide Answer Workspace

Answer: d. Directed Acyclic Graph

Explanation: DAG is a Directed Acyclic Graph, which is constructed using three


address code for optimizing the basic blocks.

51) Which of the following is used in various stages or phases of the compiler?

a. Records
b. Program
c. Symbol Table
d. Table

Hide Answer Workspace

Answer: c. Symbol Table

Explanation: A symbol table is simply a table which is created and maintained by the
compiler and used in various phases of the compiler.

52) Which of the following structure has four fields?

a. Parse tree
b. Triples
c. Indirect Triples
d. Quadruples

Hide Answer Workspace

Answer: d. Quadruples

Explanation: Quadruples are a record structure in a compiler with four fields for
implementing the three address code.

53) In which of the following tree, the leaf indicates the operand, and the interior node
represents the operator.

a. Syntax tree
b. Parser tree
c. Structured tree
d. Sematic tree

Hide Answer Workspace

Answer: a. Syntax tree

Explanation: Syntax tree is a tree in the compiler which represents operands by leaf
and operator by interior nodes.

54) Which statement is an abstract form of intermediate code?

a. 3- address
b. 2-address
c. address
d. Intermediate code

Hide Answer Workspace

Answer: a. 3-address

Explanation: None
55) Which mapping is described by the implementation of the syntax-directed
translator?

a. Parse table
b. Input
c. Output
d. Input-Output

Hide Answer Workspace

Answer: d. Input-Output

Explanation: Input-Output is a mapping which is described by the implementation


of the syntax-directed translator (SDT).

56) Which of the following function is called the canonical collection of LR(0) item.

a. FIRST
b. GOTO
c. COMPUTE
d. FOLLOW

Hide Answer Workspace

Answer: b. GOTO

Explanation: GOTO is a function that is called for defining the DFA. And, it is called
the canonical collection of LR(0) item.

57) Which of the following option is not a function of the shift-reduce parser?

a. Reduce
b. Accept
c. Go
d. Shift
Hide Answer Workspace

Answer: c. Go

Explanation: The shift-reduce parser contains only shift, reduce, error and accept
action. That's why Go is not a function of the shift-reduce parser.

58) Which of the following grammar has no two adjacent non-terminals?

a. Irregular grammar
b. Regular grammar
c. Operator
d. Precedence grammar

Hide Answer Workspace

Answer: c. Operator

Explanation: Operator grammar is the grammar that does not contain two adjacent
non-terminals on the right side of the production. It is that grammar that defines the
mathematical operators.

59) DFA is an abbreviation of.

a. Non Deterministic Finite set Automata


b. Deterministic Finite Automata
c. Non Deterministic Finite Automata
d. Deterministic Finite set Automata

Hide Answer Workspace

Answer: b. Deterministic Finite Automata

Explanation: The full form of DFA is Deterministic Finite Automata. It is also known
as Deterministic Finite Acceptor. The automata read only one symbol from the input
string at a time.
60) NFA is an abbreviation of.

a. Non Deterministic Finite set Automata


b. Deterministic Finite Automata
c. Non Deterministic Finite Automata
d. Deterministic Finite set Automata

Hide Answer Workspace

Answer: c. Non Deterministic Finite Automata

Explanation: The full form of NFA is Non-Deterministic Finite Automata. It is also


known as a Non-Deterministic Finite State-machine. An Automaton gives more than
one possible transition of the same state.

You might also like