0% found this document useful (0 votes)
2 views

cd bits

The document consists of a series of multiple-choice questions related to compilers, lexical analysis, and parsing concepts. It covers topics such as the definition of a compiler, types of errors checked by compilers, components of the compilation process, and various parsing techniques. Each question is accompanied by the correct answer and point allocation.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

cd bits

The document consists of a series of multiple-choice questions related to compilers, lexical analysis, and parsing concepts. It covers topics such as the definition of a compiler, types of errors checked by compilers, components of the compilation process, and various parsing techniques. Each question is accompanied by the correct answer and point allocation.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

CD Mid-1

MULTIPLE CHOICE

1. What is a compiler
a. system program that converts instruction c. System program that writes instruction to
to machine Language perform
b. system program that converts machine d. none of the mentioned
Language into high level ;anguage
ANS: A PTS: 1

2. Does the compiler program translate the whole source code in on step
a. No c. depending on the compiler
b. Dont know d. Yes
ANS: D PTS: 1

3. Which of the following error can a compiler check


a. Syntax Error c. Logical Errors
b. Both Syntax and Logical Errors d. Compiler cannot check errors
ANS: A PTS: 1

4.
A programmer, writes a program to multiply two numbers instead of dividing them by
mistake, how can this error be detected?
a. Compilers or interpreter c. interpreter only
b. Compiler only d. none of the above mentioned
ANS: D PTS: 1

5. Which tool is used for groupin gof characters in tokens in the compiler
a. Parser c. Code Optimizer
b. Code Generator d. Scanner
ANS: D PTS: 1

6. What is a Linker
a. It is always used before the program c. It is the same as the loader
execution
b. It id required to create the load module d. None of the above
ANS: B PTS: 1

7. Output of the lexical Analyzer is


a. Stream Character c. Set of RE
b. Syntax Tree d. Tokens
ANS: D PTS: 1

8.
In a compiler Lexical Analyzer is used for?
a. Removing Comments c. Removing white space
b. Breaking syntaxes into tokens d. All the above
ANS: D PTS: 1

9. Which part of the compiler highly used the grammar concept?


a. RG c. Lexeme
b. RE d. Pattern
ANS: C PTS: 1

10.
Which of the following is not a characteristics of compiler
a. More Execution time c. The execution takes place afet the
removal of all syntax errors
b. Debugging process is slow d. First scans the entire program and then
transform it into machine
understandable code
ANS: A PTS: 1

11. Which compiler runs on one machine and generates code for multiple machines
a. Multipass Compiler c. Cross compi;er
b. Optimizing Compiler d. One pass compiler
ANS: C PTS: 1

12. Which phase of the compiler checks the grammar of the programming?
a. Code Optimization c. Semantic Analysis
b. Syntax Analysis d. Code Generation
ANS: B PTS: 1

13. Which of the following component is important for sen=mantic analysis?


a. YACC c. LEX
b. Symbol Table d. Tyupe Checking
ANS: D PTS: 1

14. What is an object program


a. Program written in machine language c. Translation og high level language into
machine language
b. program to be translated into machine d. None of the mentioned
language
ANS: C PTS: 1

15. Which of the followiong are identified as the Lexeme


a. Identifier c. Keywords
b. Constants d. All the above
ANS: D PTS: 1

16. Lexemes can be referred to as


a. Elements of Lexicography c. Lexical Errors
b. Element sequence of alphanumeric d. None of the above
character in a token
ANS: B PTS: 1

17. If the Lexical analysis finds a lexeme with the same name as that of a reserved words it____
a. Overwrites the word c. Generated an error
b. Overwrites the functionality d. something Else
ANS: C PTS: 1

18. State True or False


Statement: A Lexical analyzer reads the source code line by line
a. True b. False
ANS: B PTS: 1

19. Which among the following is not a tool to construct lexical analyzer from a regular expression
a. LEX c. jflex
b. flex d. None of the above
ANS: D PTS: 1

20. Lexers and parsers are not found in which of the following?
a. Compiler Front end processing c. Linkers
b. Pretty Printers d. None of the above
ANS: D PTS: 1

21. Which of the followoing characters are ignored while lexical analysis
a. . c. =
b. # d. white space
ANS: D PTS: 1

22. Which of the following phase of the compiler involves type checking
a. Parsing c. Scanning
b. Syntax Directed Translation d. Semantic Analysis
ANS: B PTS: 1

23. When the expression sum=3+2 is tokenized then what is the token category of 3?
a. Identifier c. Assignment Operator
b. Integer Literals d. Addition operator
ANS: B PTS: 1

24. What are the two important lexical categorized?


a. White space c. None
b. Comments d. Comments and White Spaces
ANS: D PTS: 1

25. Lexer are often generated by leer generators, same as parser generators
a. True b. False
ANS: A PTS: 1
26. The number of tuples in the Finite State Machines are
a. 2 c. 5
b. 4 d. 6
ANS: C PTS: 1

27. The Transition function maps


a. Σ * Q -> Σ c. Σ * Σ -> Q
b. Q * Q -> Σ d. Q * Σ -> Q
ANS: D PTS: 1

28. If the number of states required to accept string ends with 10


a. 1 c. 3
b. 2 d. Can’t be represent
ANS: C PTS: 1

29. The Language of automata is


a. Is it is accepted by Automata c. If it touch final state in its lifetime
b. If it Halts d. All Languages of Automata is Automata
ANS: A PTS: 1

30. Language of Finite Automata is


a. Type 3 c. Type 1
b. Type 2 d. Type 0
ANS: D PTS: 1

31. The number of final states required to accept accept Φ in minimal finite automata
a. 1 c. 3
b. 2 d. None
ANS: D PTS: 1

32. The regular expression of all strings starts with ab and ends with bba is
a. aba*b*bba c. ab(a+b)*bba
b. ab(ab)*bba d. All
ANS: C PTS: 1

33. The basic limitations of Finite automata is


a. It can’t remember arbitrary large c. It sometimes fails to recognize regular
amount of information grammar
b. It sometimes recognize regular d. All of the mentioned
grammar
ANS: A PTS: 1

34. Concatenation Operation refers to which of the following set operations


a. Union c. Kleene Closure
b. Dot d. Positive Closure
ANS: B PTS: 1
35. Concatenation of R with Ф outputs ___________
a. Ф c. R
b. RФ d. Nione of the above

ANS: A PTS: 1

36. What constitutes the stages of the compilation process


a. Feasibility study, System design and c. Lexical Analysis, syntax analysis and
Testing Code Generation
b. Implementation and Documentation d. Nine of the above
ANS: C PTS: 1

37. A system program that brings together separately compiled modules of a program into a
form language that is suitable for execution.
a. Assembler c. Cross Compiler
b. Linking Loader d. None of the above
ANS: B PTS: 1

38. Keyword is recognized in a compiler during which phase?


a. Lexical Analysis c. Syntax analysis
b. Code Generation d. Data Flow Analysis
ANS: A PTS: 1

39. Which concept of Finite state Automata is used in compiler?


a. Code Optimization c. Parsing
b. Code Generation d. Lexical Analysis
ANS: D PTS: 1

40. Which of the following is a top down parser


a. LALR Parser c. LR Parser
b. Recursive Descent Parser d. Operator Precedence Parser
ANS: B PTS: 1

41. Leaf node in a parse tree indicates


a. Lexeme c. Terminals
b. Pattern d. Non Terminals
ANS: C PTS: 1

42. The most general phase of structured Grammar is


a. RG c. CFG
b. CSG d. UG
ANS: C PTS: 1

43. Parsing is categorized into how many types?


a. 2 c. 3
b. 4 d. 5
ANS: A PTS: 1
44. In which parsing, the parser constructs the parse tree from the start symbol and transforms
it into the input symbol
a. Bottom up parsing c. Both a and b
b. Top down parsing d. None of the above
ANS: B PTS: 1

45. 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 c. Left Recursion
b. Left factoring d. Left Parsing
ANS: C PTS: 1

46. In which derivation the right-most non-terminal symbol is replaced at each step?
a. Right Lookahead c. Right Lexeme
b. Right Most Symbol d. Right Non Terminal
ANS: B PTS: 1

47. Which Derivation is generated by the Top down parser?


a. LMD c. RMD
b. LMD in reverse d. RMD in reverse
ANS: A PTS: 1

48. Which Derivation is geneared by Bottom up parser?


a. LMD c. RMD
b. LMD in Reverse d. RMD in Reverse
ANS: D PTS: 1

49. Which among the following parser is the most powerful one?
a. SLR c. CLR
b. LALR d. LR(0)
ANS: C PTS: 1

50. Which Grammar gives multiple parse tree for the same string
a. Unambigous Grammar c. Regular Grammar
b. Ambigous Grammar d. All the above
ANS: B PTS: 1

51. The entity which generate Language is termed as


a. Automata c. Grammar
b. Tokens d. Data
ANS: C PTS: 1

52. Relocating bits used by relocating loader are specified by _____


a. Relocating Loader itself c. Assembler
b. Linker d. Macro Processor
ANS: B PTS: 1
53. Shift Reduce Parsers are
a. Top down parser c. May be top down or bottom up
b. Bottom up parser d. None of the mentioned
ANS: B PTS: 1

54. Recursive descent parsing is an example of ____________


a. Top down parsing c. Predictive Parsing
b. Bottom up parsing d. None
ANS: A PTS: 1

55. LR stands for


a. Left to right c. Right to left
b. Left to right reduction d. Right most Derivation and Left to right in
reverse
ANS: D PTS: 1

56. Which of these does not belong to CFG


a. Terminal Symbol c. Start Symbol
b. Non Terminal Symbol d. End Symbol
ANS: D PTS: 1

57. To derive a string using the production rules of a given grammar, we use
a. Scanning c. Derivation
b. Parsing d. All the above
ANS: B PTS: 1

58. Which of the following parser reaches the root symbol of the tree at last?
a. Top doen Parser c. Both a and b
b. Bottom up parser d. None
ANS: B PTS: 1

59. Which of the following parser performs top down parsing?


a. LALR parser c. Recursive Accent parser
b. LL parser d. None
ANS: B PTS: 1

60. Which of the follwoing is true for shift reduce parsers/


a. Scans and parses the input in one c. A shift command advances in the input
forward pass over the text, without any stream by one symbol
backup
b. LALR parser d. All the above
ANS: D PTS: 1

61. State True or False


Statement: LALR parsers uses tables rather than manually Recursive functions
a. True b. False
ANS: B PTS: 1
62. LALR in LALR parser stands for
a. Left aligned left right parser c. Language Argument left to right parser
b. Look ahead left to right parser d. None of the mentions
ANS: B PTS: 1

63. Which of the following parsers do not relate to Bottom up parsing?


a. LL parser c. Early Parsers
b. Recursive Descent Parser d. All the above
ANS: D PTS: 1

64. Which of the following is true for a predictive parser?


a. Recursive Descent parser c. Recursive Descent parser and no
backtracking
b. No Backtracking d. None
ANS: C PTS: 1

65. Which of the following are always unambigous?


a. Deterministic Context free grammars c. Context free grammars
b. Non-Deterministic Regular grammar d. None
ANS: A PTS: 1

66. A Grammar that only admits Ambigous Grammar is


a. Recursive Descent Parser c. Non Recursive Descent Parser
b. LR Parser d. Operator Precedence Parser
ANS: D PTS: 1

67. State True or false


Statement: R->R|T
T->ε is an ambigous grammar
a. True b. False
ANS: A PTS: 1

68. The grammar can be defined as G={V,T,P,S}, What does ‘S’ repesents
a. Accepting State c. Sensitive grammar
b. Starting Variable d. none
ANS: B PTS: 1

69. Are ambigous grammar context free?


a. Yes b. No
ANS: A PTS: 1

70. The context free grammar S->SS | 0S1 | 1S0 | €


a. Equal number of 0’s and 1’s c. Number of 0’s followed oy any number of
1’s
b. Unqual number of 0’s and 1’s d. None of the above
ANS: A PTS: 1
71. Which of the following statement is false/
a. In derivation tree, the label of each leaf c. In derivation tree, if the root of a sub
node is terminal tree is X then it is called –tree

b. In derivation tree, the label of all nodes d. None of hte menrioned


except leaf nodes is a variable

ANS: D PTS: 1

72. The construction of the canonical collection of the sets of LR (1) items are similar to the
construction of the canonical collection of the sets of LR (0) items. Which is an exception?
a. Closure and goto operations work a c. Closure and additive operations work a
little bit different little bit different
b. Closure and goto operations work d. Closure and associatively operations
similarly work a little bit different

ANS: A PTS: 1

73.
When ß is empty (A -> ß.,a), the reduction by A-> a is done by _________
a. If next symbol is a terminal c. Only If the next input symbol is A
b. Only If the next input symbol is a d. None of the above
ANS: B PTS: 1

74. If a state does not know whether it will make a shift operation or reduction for a terminal
is called _________
a. Shift/reduce conflict c. Shift conflict
b. Reduce /shift conflict d. Reduce conflict
ANS: A PTS: 1

75.
Which of the following is incorrect for the actions of A LR-Parser I) shift s ii) reduce A->ß
iii) Accept iv) reject?
a. Only I) c. I), ii) and iii)
b. I) and ii) d. I), ii) , iii) and iv)
ANS: C PTS: 1

76.
Which of these is true about LR parsing?
a. Is most general non-backtracking c. s most general non-backtracking
shift-reduce parsing shift-reduce parsing & It is still
efficient
b. It is still efficient d. None of the mentioned
ANS: C PTS: 1

77. An LR-parser can detect a syntactic error as soon as __________


a. The parsing starts c. It is possible to do so a right-to-left
scan of the input
b. It is possible to do so a left-to-right d. Parsing ends
scan of the input
ANS: B PTS: 1

78. What is the similarity between LR, LALR and SLR?


a. Use same algorithm, but different c. Their Parsing tables and algorithm are
parsing table similar but uses top down approach
b. Same parsing table, but different d. Both Parsing tables and algorithm are
algorithm differen
ANS: A PTS: 1

79.
Which of these is also known as look-head LR parser?
a. SLR c. LLR
b. LR d. None of the above
ANS: C PTS: 1

80.
Which of the following describes a handle (as applicable to LR-parsing) appropriately?
a. Position where next reduce or shift c. Used for reduction in a coming-up
operation will occur step along with a position in the
sentential form where the next shift or
reduce operation will occur
b. The next step has use of Non-terminal d. Used in the next step for reduction
for reduction along with a position in the sentential
form where the right hand side of the
production may be found
ANS: D PTS: 1

81. Which of the following statement is false


a. nambiguous grammar has both kind of c. LALR is more powerful than SLR
derivations
b. An LL(1) parser is top-down parser d. Ambiguous grammar can’t be LR(k)
ANS: A PTS: 1

82.
Which one of the following is true at any valid state in shift-recuce parsing?
a. At the bottom we find the prefixes c. Stack contains ony viable prefixes
b. None d. Stack consists of viable prefixes
ANS: C PTS: 1

83. Which of the following pairs is the most powerful?


a. SLR,LALR c. SLR,CLR
b. CLR,LALR d. LALR,CLR
ANS: C PTS: 1
84. Find out the grammar for the below Productions
S->CC
C->cC/d
a. LL(1) c. LALR(1) but not SLR(1)
b. SLR(1) but not LL(1) d. LR(1) but not LALR(1)
ANS: A PTS: 1

85. Assume that SLR parser for a grammar G has n1 states and LALR parser for G has n1 states
a. n1 is necessarily less than n2 c. n1 is necessarily greater than n2
b. n1 is necessarily equal to n2 d. None of the mentioned
ANS: B PTS: 1

86. Which of the following suffices to convert an arbitrary CFG to an LL(1) Grammar?
a. Removing Left recursion only c. Factoring & left recursion removal
b. Factoring of the Grammar alone d. None
ANS: D PTS: 1

87. The grammar A->AA/(A)/e is not suitable for predictive parsing because the grammar is
a. Ambigous c. Right Recursive
b. Left Recursive d. An operator grammar
ANS: B PTS: 1

88. Which of the following statement is false?


a. Left as well as right most derivations c. LALR is more powerful than SLR
can be in Unambiguous grammar
b. An LL(1) parser is a top down parser d. Ambigous grammar can;t be LR(k)
ANS: A PTS: 1

89. Consder the grammar given below


A’=>A
A->aXb/c/dX
X->f^A/A
Let i0=closure ({A’->.A}) The number of item in set Goto(I0,a) is
a. 4 c. 6
b. 5 d. 7
ANS: C PTS: 1

90. The item generated by the production A->€ is


a. A->. c. A->.€
b. A->€. d. A->€
ANS: A PTS: 1

91. Consider the following statement


Statement 1: LALR is morepowerful than CLR
Statement 2: SLR is more poerful than LALR
Which one of the above is correct?
a. Statement 1 is true and statement 2 is false c. Statement 1 is true and statement 2 is true
b. Statement 1 is false and statement 2 is true d. Statement 1 is false and statement 2 is
false
ANS: D PTS: 1

92. Consider the grammar given below


S’-> S
S-> <L>/id
L->L,S/S
Let I0=Closure({S’->.S}.The number of items in the set Goto(I0,<) is
a. 2 c. 4
b. 3 d. 5
ANS: D PTS: 1

93. What is the similarity between LR, LALR and SLR?


a. Use same algorithm, but different parsing c. Their Parsing tables and algorithm are
table. similar but uses top down approach
b. Same parsing table, but different d. Both Parsing tables and algorithm are
algorithm different
ANS: A PTS: 1

94. An LR-parser can detect a syntactic error as soon as __________


a. The parsing starts c. It is possible to do so a right-to-left scan
of the input
b. It is possible to do so a left-to-right scan d. Parsing ends
of the input
ANS: B PTS: 1

95. Which of these is true about LR parsing?


a. Is most general non-backtracking c. Is most general non-backtracking
shift-reduce parsing shift-reduce parsing & It is still efficient
b. It is still efficient d. None of the mentioned
ANS: C PTS: 1

96. Which of the following is incorrect for the actions of A LR-Parser I) shift s ii) reduce A->ß iii)
Accept iv) reject?
a. Only I c. I, ii and iii
b. I and ii d. I, ii , iii and iv
ANS: C PTS: 1

97. If a state does not know whether it will make a shift operation or reduction for a terminal is called
_________
a. Shift/reduce conflict c. Shift conflict
b. Reduce /shift conflict d. Reduce conflict
ANS: A PTS: 1

98. When there is a reduce/reduce conflict?


a. If a state does not know whether it will c. If a state does not know whether it will
make a shift operation using the make a reduction operation using the
production rule i or j for a terminal production rule i or j for a terminal
b. If a state does not know whether it will d. None of the mentioned
make a shift or reduction operation using
the production rule i or j for a terminal
ANS: C PTS: 1

99. When ß (in the LR(1) item A -> ß.a,a) is not empty, the look-head ________
a. Will be affecting c. Shift will take place
b. Does not have any affect d. Reduction will take place
ANS: B PTS: 1

100. The construction of the canonical collection of the sets of LR (1) items are similar to the
construction of the canonical collection of the sets of LR (0) items. Which is an exception?
a. Closure and goto operations work a little c. Closure and additive operations work a
bit different little bit different
b. Closure and goto operations work d. Closure and associatively operations work
similarly a little bit different
ANS: A PTS: 1

You might also like