Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 17

1.

One of the following is different


A. Code Generation C. Semantic analysis
B. Parser D. None
2. One of the following is not an application of finite automata
A. It play important role in compiler design
B. Used in design and analysis of complex software
C. Used in design and analysis of hardware system
D. To prove the correctness of the program
E. None
3. One of the following is wrong in the designing of pattern
A. [a-f] matches a, b, c, d, e, or f E. C & D
B. [0-9] matches any digit F. None
C. X+ matches zero or more of X
D. X* matches one or more of X

4. Which one of the following is true about regular expression

A. unary operator * has highest precedence


B. | has highest precedence
C. Concatenation has lowest precedence
D. None

1|1 7 P a g e s
5. One of the following is not correct

A. A parser gets a stream of tokens from the scanner, and determines if the syntax of the
program is correct

B. Load and Go Compilers generates machine code & then immediately executes it.

C. Single Pass Compilers better than Multi-Pass Compilers

D. A & C

6. In ¿(1) Parsing Algorithm, if the current symbol on the top of the stack is X and the current
input isa , then which one of the following is true?
A) If X =a=$ then the parser halts and announces a successful completion of parsing.
B) If X =a and a ≠ $ then the parser pops X off the stack and advances the input pointer to
the next symbol.
C) If X is a non-terminal then the program consults entry M [ X , a] which can be an X -
production or an error entry.
D) All.

7. One of the following is correct about types of error ?


A. Lexical error :- Error in structure D. Semantic error:- infinitely
B. Syntactic error :- recursive call
Unbalanced parenthesis E. None
C. Logical error:- Missing
operators
8. One of the following is Correct about Recursive descent parse
A. It uses Backtracking strategy C. It uses stack for grammar
B. left recursion grammar is acceptable D. It uses parsing table
9. One of the following statement is correct about error recovery strategy's
A. Panic-mode recovery – use discard input symbols one at a time strategy
B. Error productions – make as few changes as possible in the program
C. Phrase-level recovery – it is local corrections by replacing prefix of remaining input
D. Global correction –augment the grammar with productions
E. A & D F. A & C
10. One of the following needs to be checked during Optimization
A. Redundant instruction D. Algebraic expression simplification
B. Unreachable code E. Strength reduction
C. Flow of control F. All

2|1 7 P a g e s
11. One of the following is wrong about bottom up parser
A. Parsing starts with the input symbol
B. Shift-reduce parser is general style
C. Parse tree from the root node gradually moving down to the leaf nodes.
D. Starts from the leaf nodes of a tree and works in upward direction.
E. A & C F. B and D
12. One of the following is wrong about LR parser
A. LR parser is a non-recursive
B. Simple LR Works on intermediate size of grammar
C. Difference of All type of LR parsing only the parsing table
D. It use stack to store sequence of grammar symbols
E. None
13. One the following is Conflict during shift/reduce parsing is correctly described
A. shift/reduce conflict is when parser cannot decide whether it should shift or reduce
B. shift/shift conflict is when parser cannot decide which of the several productions it should use
for a shift
C. reduce/reduce conflict parser cannot decide which of the several productions it should use for
a reduction
D. A and B E. Except B
14. One the following can not be an attribute can represent of SDT
A. String D. Memory location
B. Number E. None
C. Type
15. One the following semantic rules evaluating method is correctly decried
A. Parse rule based methods:- The evaluation order is chosen without considering the semantic
rules
B. Rule based methods:- evaluation order is predetermined at compiler-construction time.
C. Oblivious methods:- for each input, the compiler finds an evaluation order.
D. ALL
16. One of the following cant be an examples of static checks

3|1 7 P a g e s
A. Type Checking
B. Flow control check
C. Uniqueness checks
D. Name related checks
17. 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
18. Which of the following is a stage of compiler design?
a) Semantic analysis
b) Intermediate code generator
c) Code generator
d) All

19. 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

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

a) Second
b) Third
c) First
d) All of the mentioned

21. 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

22. 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

4|1 7 P a g e s
d) None of them are regular

23. 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

24. Regular expressions can be used only for values of type string and number.

a) True
b) False

25. The production Grammar is {S->aSbb,S->abb} is __________ grammar.


a) Type-3
b) Type-2
c) Type-1
d) Type-0
26. Regular expression x/y denotes which of the following set?
a) {x,y}
b) {xy}
c) {x}
d) {y}
27. The regular expressions denote zero or more instances of an x or y is?
a) (x+y)
b) (x+y)*
c) (x* + y)
d) (xy)*
28. A system program that combines separately compiled modules of a program
into a form suitable for execution is called ___________
a) Assembler
b) Linking loader
c) Cross compiler
d) None of the mentioned
29. A compiler for a high-level language that runs on one machine and
produces code for a different machine is called ___________
a) Optimizing compiler
b) One pass compiler
c) Cross compiler
d) Multipass compiler
30. Cross-compiler is a compiler __________
a) Which is written in a different language from the source language?
b) That generates object code for the machine it’s running on.
c) Which is written in the same language as the source language?
d) That runs on one machine but produces object code for another machine

5|1 7 P a g e s
31. Cross compiler is used in Bootstrapping.
a) True
b) False
32. Is GCC a cross Complier.
a) Yes
b) No
33. If we compile the sam.c file with the command “gcc -o sam sam.c”, then
the executable file will be?
a) a.out
b) sam
c) sam.out
d) None of the mentioned
34. What is the output of lexical analyzer?
a) A set of RE
b) Syntax Tree
c) Set of Tokens
d) String Character
35. Which of the following is true for operator precedence parsing?
a) For all pair of non-terminal
b) For all pair of non-terminals
c) To delimit the handle
d) None of the mentioned
36. Which of the following are Lexemes?
a) Identifiers
b) Constants
c) Keywords
d) All
37. What is the output of lexical analyzer?
a) A set of RE
b) Syntax Tree
c) Set of Tokens
d) String Character
38. Which concept of FSA is used in the compiler?
a) Lexical analysis
b) Parser
c) Code generation
d) Code optimization
39. Parsing is also known as ________
a) Lexical Analysis
b) Syntax Analysis
c) Semantic Analysis
d) Code Generation
40. A system program that brings together separately compiled modules of a
program into a form language that is suitable for execution.
a) Assembler
b) Linking loader

6|1 7 P a g e s
c) Cross compiler
d) None of the mentioned
41. You can use RE, if you expect the value of a property to change in an
unpredictable way each time its run.
a) True
b) False
42. RE can be used only for values of type string and number.
a) True
b) False
43. The RE gives none or many instances of an x or y is?
a) (x+y)
b) (x+y)*
c) (x* + y)
d) (xy)
44. The regular expression have all strings of 0′s and 1′s with no two
consecutive 0′s is?
a) (0+1)
b) (0+1)*
c) (0+∈) (1+10)*
d) (0+1)* 011
45. The regular expression with all strings of 0′s and 1′s with at least two
consecutive 0′s is?
a) 1 + (10)*
b) (0+1)*00(0+1)*
c) (0+1)*011
d) 0*1*2*
46. Consider the production of the grammar S->AA A->aa A->bb Describe the
language specified by the production grammar.
a) L = {aaaa,aabb,bbaa,bbbb}
b) L = {abab,abaa,aaab,baaa}
c) L = {aaab,baba,bbaa,bbbb}
d) L = {aaaa,abab,bbaa,aaab}
47. Maximum number of states of a DFA converted from an NFA with nstates
is?
a) n
b) n2
c) 2n
d) None of the mentioned
48. A finite automata recognizes ____________
a) Any Language
b) Context Sensitive Language
c) Context Free Language
d) Regular Language
49.
50. Which is the correct NDFA for the following mentioned expression?
(ab)*∪(aba)*

7|1 7 P a g e s
a)

b)

c)
d) None of the mentioned

51. The regular languages are not closed under ___________


a) Concatenation
b) Union
c) Kleene star
d) Complement
52. NFAs are ________ DFAs.
a) Larger than
b) More expressive than
c) Less expressive than
d) Equally expressive as
53. Conversion of a DFA to an NFA __________
a) Is impossible
b) Requires the subset construction
c) Is Chancy
d) Is nondeterministic
54. A regular language corresponds to __________
a) An alphabet
b) Set of strings over an alphabet
c) A DFA only
d) A DFA or an NFA
55. The subset construction shows that every NFA accepts a __________
a) String
b) Function
c) Regular language
d) Context-free language
56. Construct a NDFA for the following regular expression.
8|1 7 P a g e s
(a∪b)*aba(a∪b)*

a)

b)

c)
d) None of the mentioned

57. Which is the application of NFA?


a) A regular language is produced by union of two regular languages
b) The concatenation of two regular languages is regular
c) The Kleene closure of a regular language is regular
d) All of the mentioned
58. For every NFA a deterministic finite automaton (DFA) can be found that
accepts the same language.
a) True
b) False
59. Like DFAs, NFAs only recognize regular languages.
a) True
b) False
60. In a compiler the module that checks every character of the source text is
called __________
a) The code generator
b) The code optimizer
c) The lexical analyzer
d) The syntax analyzer
61. The context free grammar is ambiguous if ______________
a) The grammar contains non-terminals
b) Produces more than one parse tree
c) Production has two non-terminals side by side
d) None of the mentioned

9|1 7 P a g e s
62. What is another name for Lexical Analyser?
a) Linear Phase
b) Linear Analysis
c) Scanning
d) All of the mentioned
63. An individual token is called ________
a) Lexeme
b) Lex
c) Lexeme & Lex
d) None of the mentioned
64. Lexical Analyser’s Output is given to Syntax Analysis.
a) True
b) False
65. Which phase of the compiler is Lexical Analyser?
a) First
b) Second
c) Third
d) None of the mentioned
66. The process of forming tokens from an input stream of characters is called
__________
a) Liberalisation
b) Characterisation
c) Tokenization
d) None of the mentioned
67. What goes over the characters of the lexeme to produce value?
a) Scanner
b) Parser
c) Evaluator
d) Lexical generator
68. Which phase of the compiler is Syntax Analysis?
a) First
b) Second
c) Third
d) None of the mentioned
69. Syntax Analyser takes Groups Tokens of source Program into Grammatical
Production.
a) True
b) False
70. Parsers are expected to parse the whole code.
a) True
b) False
71. A grammar for a programming language is a formal description of
_______________
a) Syntax
b) Semantics

10 | 1 7 P a g e s
c) Structure
d) Library
72. Which of these is not true about the Symbol Table?
a) All the labels of the instructions are symbols
b) Table has entry for symbol name address value
c) Perform the processing of the assembler directives
d) Created during pass 1
73. A compiler can check?
a) Logical Error
b) Syntax Error
c) Both Logical and Syntax Error
d) Not Logical and Syntax Error
74. Select a Machine Independent phase of the compiler.
a) Syntax Analysis
b) Intermediate Code generation
c) Lexical Analysis
d) All of the mentioned
75. A system program that combines the separately compiled modules of a
program into a form suitable for execution?
a) Assembler
b) Compiler
c) Linking Loader
d) Interpreter
76. Which of the following system software resides in the main memory?
a) Text Editor
b) Assembler
c) Linker
d) Loader
77. Output file of Lex is __________ the input file is Myfile.
a) Myfile.e
b) Myfile.yy.c
c) Myfile.lex
d) Myfile.obj
78. By whom is the symbol table created?
a) Compiler
b) Interpreter
c) Assembler
d) None of the mentioned
79. What does a Syntactic Analyser do?
a) Maintain Symbol Table
b) Collect type of information
c) Create parse tree
d) None of the mentioned
80. 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

11 | 1 7 P a g e s
c) Number of 0’s followed by any number of 1’s
d) None of the mentioned
81. A regular Grammar is a _________
a) CFG
b) Non CFG
c) English Grammar
d) None of the mentioned
82. A CFG is closed under _________
a) Union
b) Kleene star
c) Concatenation
d) None of the mentioned
83. Which of the following is true?
a) (01)*0 = 0(10)*
b) (0+1)*0(0+1)*1(0+1) = (0+1)*01(0+1)*
c) (0+1)*01(0+1)*+1*0* = (0+1)*
d) All of the mentioned
84. A language is regular if and only if?
a) Accepted by DFA
b) Accepted by PDA
c) Accepted by LBA
d) Accepted by Turing machine
85. What is Regular grammar?
a) Context free grammar
b) Non context free grammar
c) English grammar
d) None of the mentioned
86. Which of the following is not a regular expression?
a) [(a+b)*-(aa+bb)]*
b) [(0+1)-(0b+a1)*(a+b)]*
c) (01+11+10)*
d) (1+2+0)*(1+2)*
87. Left Linear grammar can be converted to Right Linear grammar.
a) Yes
b) No
88. What is CFG?
a) Compiler
b) A language expression
c) Regular Expression
d) None of the mentioned
89. Which of the following statement is true?
a) Every language that is defined by regular expression can also be defined
by finite automata
b) Every language defined by finite automata can also be defined by regular
expression

12 | 1 7 P a g e s
c) We can convert regular expressions into finite automata
d) All of the mentioned
90. Which of the following statements is false?
a) Left as well as right most derivations can be in Unambiguous grammar
b) An LL (1) parser is a top-down parser
c) LALR is more powerful than SLR
d) Ambiguous grammar can’t be LR (k)
91. Which of the following suffices to convert an arbitrary CFG to an LL(1)
grammar?
a) Removing left recursion only
b) Factoring the grammar alone
c) Factoring & left recursion removal
d) None of the mentioned
92. Which one of the following is a top-down parser?
a) Recursive descent parser
b) Operator precedence parser
c) An LR(k) parser
d) An LALR(k) parser
93. Consider the grammar defined by the following production rules:

S --> T * P

T --> U | T * U

P --> Q + P | Q

Q --> Id

U --> Id

94. Which one of the following is TRUE?


a) + is left associative, while ∗ is right associative
b) + is right associative, while ∗ is left associative
c) Both + and ∗ are right associative
d) Both + and ∗ are left associative
95. Which of the following statements is false?
a) Unambiguous grammar has both kind of derivations
b) An LL(1) parser is a top-down parser
c) LALR is more powerful than SLR
d) Ambiguous grammar can’t be LR(k)
96. The action of parsing the source program into proper syntactic classes is
called __________
a) Syntax Analysis
b) Lexical Analysis
c) Interpretation analysis
d) General Syntax Analysis

13 | 1 7 P a g e s
97. A bottom up parser generates __________
a) Right most derivation
b) Rightmost derivation in reverse
c) Leftmost derivation
d) Leftmost derivation in reverse
98. A grammar that produces more than one parse tree for some sentence is
called __________
a) Ambiguous
b) Unambiguous
c) Regular
d) None of the mentioned
99. An optimizer Compiler __________
a) Is optimized to occupy less space
b) Is optimized to occupy less space & Optimize the code
c) Optimize the code
d) None of the mentioned
100. The linker __________
a) Is similar to interpreter
b) Uses source code as its input
c) Is required to create a load module
d) None of the mentioned
101. The optimization which avoids test at every iteration is?
a) Loop unrolling
b) Loop jamming
c) Constant folding
d) None of the mentioned
102. An intermediate code form is __________
a) Postfix notation
b) Syntax Trees
c) Three Address code
d) All of the mentioned
103. Which of the following actions an operator precedence parser may take
to recover from an error?
a) Insert symbols onto the stack
b) Delete symbols from the stack
c) Inserting or deleting symbols from the input
d) All of the mentioned
104. What is the output of lexical analyzer?
a) A set of regular expression
b) Syntax tress
c) Set of Token
d) String of Characters
105. Which of the following is used for grouping of characters into tokens?
a) Parser
b) Code optimization

14 | 1 7 P a g e s
c) Code generator
d) Lexical analyser
106. Shift reduce parsers are __________
a) Top down parser
b) Bottom up parser
c) Maybe both
d) None of the mentioned
107. A bottom up parser generates __________
a) Right most derivation
b) Right most derivation in reverse
c) Left most derivation
d) Left most derivation in reverse
108. An optimizing compiler __________
a) Is optimized to occupy less space
b) Is optimized to take less time for execution
c) Optimized the code
d) None of the mentioned
109. In a bottom up evaluation of a syntax direction definition, inherited
attributes can __________
a) Always be evaluated
b) Be evaluated only if the definition is L –attributed
c) Evaluation only done if the definition has synthesized attributes
d) None of the mentioned
110. What is the similarity between LR, LALR and SLR?
a) Use same algorithm, but different parsing table
b) Same parsing table, but different algorithm
c) Their Parsing tables and algorithm are similar but uses top down
approach
d) Both Parsing tables and algorithm are different
111. An LR-parser can detect a syntactic error as soon as __________
a) The parsing starts
b) It is possible to do so a left-to-right scan of the input
c) It is possible to do so a right-to-left scan of the input
d) Parsing ends
112. When there is a reduce/reduce conflict?
a) If a state does not know whether it will make a shift operation using the
production rule i or j for a terminal
b) If a state does not know whether it will make a shift or reduction
operation using the production rule i or j for a terminal
c) If a state does not know whether it will make a reduction operation using
the production rule i or j for a terminal
d) None of the mentioned
113. Which of the following features cannot be captured by CFG?
a) Syntax of if-then-else statements
b) Syntax of recursive procedures

15 | 1 7 P a g e s
c) A variable is declared before its use
d) Matching nested parenthesis
114. The identification of common sub-expression and replacement of run-
time computations by compile-time computations is _____________
a) Local optimization
b) Loop optimization
c) Constant folding
d) Data flow analysis
115. Which of the following strings is generated by the grammar?

S->bA S->aB

A->a B->b

A->aS B->bS

A->bAA B->aBB

a) aaaabb
b) aabbbb
c) aabbab
d) abbbba

116. An LALR(1) parser for a grammar can have shift-reduce (S-R) conflicts
if and only if ___________
a) The SLR(1) parser for G has S-R conflicts
b) The LR(1) parser for G has S-R conflicts
c) The LR(0) parser for G has S-R conflicts
d) The LALR(1) parser for G has reduce-reduce conflicts
117. What data structure in a complier is used for managing information
about variables and their attributes?
a) Abstract syntax tree
b) Symbol table
c) Semantic stack
d) Parse table
118. The action of parsing the source program into proper syntactic classes is
called ________
a) Syntax analysis
b) Lexical analysis
c) Interpretation analysis
d) General syntax analysis
119. The action of parsing the source program into proper syntactic classes is
called ________
a) Syntax analysis
b) Lexical analysis
c) Interpretation analysis
d) General syntax analysis
16 | 1 7 P a g e s
120. Bottom up parsing involves __________
a) Shift reduce
b) Handle pruning
c) Shift reduce & Handle pruning
d) None of the mentioned
121. The main memory in a Personal Computer (PC) is made of __________
a) Cache memory
b) Static RAM
c) Dynamic Ram
d) Cache memory & RAM
122. Choose the correct statement.
a) CFG is not LR
b) Ambiguous Grammar can never be LR
c) CFG is not LR & Ambiguous Grammar can never be LR
d) None of the mentioned
123. LR stands for ___________
a) Left to right
b) Left to right reduction
c) Right to left
d) Right most derivation and Left to right and a in reverse
124. The bottom-up parsing method is also called

a) Shift reduce parsing


b) Predictive parsing
c) Recursive descent parsing
d) None of these

125. Synthesized attribute can be easily simulated by a

a) LR grammar
b) LL grammar
c) Ambiguous grammar
d) None of these

126. Semantic errors can be detected at

a) Compile time only


b) Run-time only
c) Both (a) and (b)
d) None of these

127. Grammar of the programming is checked at _____ phase of compiler.

a) Syntax analysis
b) Semantic analysis
c) Code generation
d) Code optimization

17 | 1 7 P a g e s

You might also like