Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
nmims post
Objective Type Set
Online MCQ Assignment
Question Solution
Solved Question
Uncategorized

Multiple choice question for engineering

Set 1

1. Input to code generator
a) Source code
b) Intermediate code
c) Target code
d) All of the mentioned

View Answer

Answer: b [Reason:] Intermediate code is the input to the code generator.

2. A synthesized attribute is an attribute whose value at a parse tree node depends on
a) Attributes at the siblings only
b) Attributes at parent node only
c) Attributes at children nodes only
d) None of the mentioned

View Answer

Answer: c [Reason:] Synthesized attribute’s value depend on children node only.

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

View Answer

Answer: c [Reason:] Bottom-up parsing identifies and processes the text’s lowest-level, before its mid-level structures, and the highest-level overall structure to last are left.

4. The graph that shows basic blocks and their successor relationship is called
a) DAG
b) Flow Chart
c) Control Graph
d) Hamilton graph

View Answer

Answer: b [Reason:] Flow chart shows basic blocks.

5. _________ or scanning is the process where the stream of characters making up the source program is read from left to right and grouped into tokens.
a) Lexical Analysis
b) Diversion
c) Modelling
d) None of the mentioned

View Answer

Answer: a [Reason:] Lexical analysis is the process of converting a sequence of characters into a sequence of tokens.

6. The output of a lexical analyzer is
a) Machine code
b) Intermediate code
c) A stream of tokens
d) A parse tree

View Answer

Answer: c [Reason:] The output of lexical analyser is output token.

7. _____________ is a graph representation of a derivation
a) The parse tree
b) Oct tree
c) Binary tree
d) None of the mentioned

View Answer

Answer: a [Reason:] Parse tree is a representation of the derivation.

8. Which of the following symbols table implementation is based on the property of locality of reference?
a) Hash Table
b) Search tree
c) Self organizing list
d) Linear list

View Answer

Answer: c [Reason:] Self Organizing list is based on locality of reference.

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

View Answer

Answer: a [Reason:] Recursive Descent parsing is LL (1) parsing which is top down parsing.

10. Assume that the SLR parser for a grammar G has n1 states and the LALR parser for G has n2 states. Hence which one is true?
a) n1 is necessarily less than n2
b) n1 is necessarily equal to n2
c) n1 is necessarily greater than n2
d) None of the mentioned

View Answer

Answer: b [Reason:] Bottom-up parsing identifies and processes the text’s lowest-level, before its mid-level structures, and the highest-level overall structure to last are left.

Set 2

1. S → C C
C → c C | d
The grammar is
a) LL(1)
b) SLR(1) but not LL(1)
c) LALR(1) but not SLR(1)
d) LR(1) but not LALR(1)

View Answer

Answer: a [Reason:] Since there is no conflict, the grammar is LL (1) hence a predictive parse table with no conflicts can be constructed.

2. 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)

View Answer

Answer: a [Reason:] If a grammar has more than one leftmost (or rightmost) derivation the grammar is ambiguous.

3. Which of the following derivations does a top-down parser use while parsing an input string?
a) Leftmost derivation
b) Leftmost derivation in reverse
c) Rightmost derivation
d) Rightmost derivation in reverse

View Answer

Answer: a [Reason:] Left to right constructing leftmost derivation of the sentence.

4. Given the following expression grammar:
E -> E * F | F + E | F
F -> F – F | id
Which of the following is true?
a) * has higher precedence than +
b) – has higher precedence than *
c) + and — have same precedence
d) + has higher precedence than *

View Answer

Answer: b [Reason:] e.g. input is 3*4-5 r

         E
     /  |  
     E   *   F
  |     / | 
  F    F - F
  |    |     |
id (3) id (4) id (5)

First ‘- ‘ is be evaluated then ‘ *’

5. Which one of the following is true at any valid state in shift-reduce parsing?
a) At the bottom we find the prefixes
b) None of the mentioned
c) Stack contains only viable prefixes
d) Stack consists of viable prefixes

View Answer

Answer: c [Reason:] The prefixes on the stack of a shift-reduce parser are called viable prefixes.

6. In the context of abstract-syntax-tree and control-flow-graph.
Which one of the following is true?
a) In both AST and CFG if node N2 be the successor of node N1.
b) For any input program, neither AST nor CFG will contain a cycle
c) The max no. of successors of a node in an AST and a CFG depends on the input program
d) None of the mentioned

View Answer

Answer: c [Reason:] Successors depends on input .

7. Match the following:

      List-I                  List-II
A. Lexical analysis       1. Graph coloring
B. Parsing                2. DFA minimization
C. Register allocation    3. Post-order traversal
D. Expression evaluation  4. Production tree

A B C D
(a) 2 3 1 4
(b) 2 1 4 3
(c) 2 4 1 3
(d) 2 3 4 1

View Answer

Answer: c [Reason:] The entire column an items matches the Column B items in a certain way.

7. Which of the following pairs is the most powerful?
a) SLR, LALR
b) Canonical LR ,LALR
c) SLR canonical LR
d) LALR canonical LR

View Answer

Answer: c [Reason:] parser algorithm is simple.

8. Consider the following grammar G.
S → F ⎪ H
F → p ⎪ c
H → d ⎪ c
Which one is true?
S1: All strings generated by G can be parsed with help of LL (1).

S2: All strings generated by G can be parsed with help of LR (1).
a) Only S1
b) Only S2
c) Both S1 S2
d) None of the mentioned

View Answer

Answer: d [Reason:] There is ambiguity as the string can be derived in 2 possible ways. First Leftmost Derivation S → F F → c Second Leftmost Derivation S → H H → c .

9. What is the maximum number of reduce moves that can be taken by a bottom-up parser for a grammar with no epsilon- and unit-production to parse a string with n tokens?
a) n/2
b) n-1
c) 2n-1
d) 2^n

View Answer

Answer: b [Reason:] the moves are n-1.

10. Consider the following two sets of LR (1) items of an LR (1) grammar.

   X -> c.X, c/d
   X -> .cX, c/d
   X -> .d, c/d
   X -> c.X, $
   X -> .cX, $
   X -> .d, $

Which one is false?
1. Cannot be merged since look ahead’s are different.
2. Can be merged but will result in S-R conflict.
3. Can be merged but will result in R-R conflict.
4. Cannot be merged since goto on c will lead to two different sets.
a) 1 only
b) 2 only
c) 1 and 4 only
d) 1, 2, 3 and 4 only

View Answer

Answer: d [Reason:] All these are valid reasons.

Set 3

1. Assume statements S1 and S2 defined as: S1: L2-L1 is recursive enumerable where L1 and L2 are recursive and recursive enumerable respectively. S2: The set of all Turing machines is countable. Which of the following is true?
a) S1 is correct and S2 is not correct
b) Both S1 and S2 are correct
c) Both S1 and S2 are not correct
d) S1 is not correct and S2 is correct

View Answer

Answer: b [Reason:] The assumptions of statement S1 and S2 are correct.

2. A context free language is called ambiguous if
a) It has 2 or more left derivations for some terminal string ѡ є L (G)
b) It has 2 or more right derivations for some terminal string ѡ є L (G)
c) Both of the mentioned
d) None of the mentioned

View Answer

Answer: b [Reason:] A context-free grammar (CFG) is a set of recursive rewriting rules (or productions) used to generate patterns of strings.

3. Which of the following statement is false?
a) The CFG can be converted to Chomsky normal form
b) The CFG can be converted to Greibach normal form
c) CFG is accepted by pushdown automata
d) None of the mentioned

View Answer

Answer: d [Reason:] All the statements follow the rules.

4. The context free grammar S → A111|S1, A → A0 | 00 is equivalent to
a) {0ⁿ1ᵐ | n=2, m=3}
b) {0ⁿ1ᵐ | n=1, m=5}
c) {0ⁿ1ᵐ | n should be greater than two and m should be greater than four}
d) None of the mentioned

View Answer

Answer: a [Reason:] S-> A111 S->00111 (A->00).

5. 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
c) Number of 0’s followed by any number of 1’s
d) None of the mentioned

View Answer

Answer: a [Reason:] S->SS S->0S1S S->0S11S0 S->0110.

6. Which of the following statement is false?
a) In derivation tree, the label of each leaf node is terminal
b) In derivation tree, the label of all nodes except leaf nodes is a variable
c) In derivation tree, if the root of a sub tree is X then it is called –tree
d) None of the mentioned

View Answer

Answer: d [Reason:] All of them are true regarding a derivation tree.

7. Push down automata accepts which language
a) Context sensitive language
b) Context free language
c) Recursive language
d) None of the mentioned

View Answer

Answer: b [Reason:] PDA accepts CFG.

8. A regular Grammar is a?
a) CFG
b) Non CFG
c) English Grammar
d) None of the mentioned

View Answer

Answer: a [Reason:] Regular grammar is CFG.It restricts its rules to a single non terminal on left hand side.

9. A CFG is closed under
a) Union
b) Kleene star
c) Concatenation
d) None of the mentioned

View Answer

Answer: d [Reason:] CFG is closed under the above mentioned 3 operations.

10. Which of these does not belong to CFG
a) Terminal Symbol
b) Non terminal Symbol
c) Start symbol
d) End Symbol

View Answer

Answer: d [Reason:] CFG consist of terminal non terminal start symbol set of production rules but does not have an end symbol.

Set 4

1. DAG representation of a basic block allows
a) Automatic detection of local common sub expressions
b) Detection of induction variables
c) Automatic detection of loop variant
d) None of the mentioned

View Answer

Answer: a [Reason:] It detects local sub expression.

2. Inherited attribute is a natural choice in
a) Tracking declaration of a variable
b) Correct use of L and R values
c) Both of the mentioned
d) None of the mentioned

View Answer

Answer: a [Reason:] These attribute keep a check on variable declaration.

3. An intermediate code form is
a) Post-fix notation
b) Syntax Trees
c) Three Address code
d) All of the mentioned

View Answer

Answer: d [Reason:] Intermediate code generator receives input from its predecessor phase, semantic analyzer, in the form of an annotated syntax tree.

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

View Answer

Answer: d [Reason:] All these symbols are used to recover operator precedence parser from an error.

5. The output of lexical analyzer is
a) A set of regular expression
b) Syntax tress
c) Set of Token
d) String of Characters

View Answer

Answer: c [Reason:] Lexical analysis is the process of converting a sequence of characters into a sequence of tokens.

6. Which of the following is used for grouping of characters into tokens?
a) Parser
b) Code optimization
c) Code generator
d) Lexical analyser

View Answer

Answer: d [Reason:] Lexical analysis is the process of converting a sequence of characters into a sequence of tokens.

7. Shift reduce parsers are
a) Top down parser
b) Bottom up parser
c) Maybe both
d) None of the mentioned

View Answer

Answer: b [Reason:] This corresponds to starting at the leaves of the parse tree. It can be thought of. A process of reducing the string in question to the start symbol of the grammar. Bottom-up parsing is also known as shift-reduce parsing.

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

View Answer

Answer: b [Reason:] This corresponds to starting at the leaves of the parse tree. It can be thought of. a process of reducing the string in question to the start symbol of the grammar. Bottom-up parsing is also known as shift-reduce parsing.

9. A garbage is
a) Unallocated storage
b) Allocated storage whose access paths are destroyed?
c) Allocated storage
d) Uninitialized storage

View Answer

Answer: b [Reason:] These are more like memory loacations with values whose pointers have been revoked.

10. A 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

View Answer

Answer: c [Reason:] As the name suggests that it optimizes the code.

Set 5

1. Which of these is also known as look-head LR parser?
a) SLR
b) LR
c) LLR
d) None of the mentioned

View Answer

Answer: c [Reason:] LLR is the look ahead parser.

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

View Answer

Answer: a [Reason:] The common grounds of these 3 parser is the algorithm but parsing table is different.

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

View Answer

Answer: b [Reason:] Error is found when it the input string is scanned.

4. Which of these is true about LR parsing ?
a) Is most general non-backtracking shift-reduce parsing
b) It is still efficient
c) Both of the mentioned
d) None of the mentioned

View Answer

Answer: c [Reason:] LR parsers are a type of bottom-up parsers that efficiently handle deterministic context-free languages in guaranteed linear time.

5. 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)
b) I) and ii)
c) I), ii) and iii)
d) I), ii) , iii) and iv)

View Answer

Answer: c [Reason:] Only reject out of the following is a correct LR parser action.

6. If a state does not know whether it will make a shift operation or reduction for a terminal is called
a) Shift/reduce conflict
b) Reduce /shift conflict
c) Shift conflict
d) Reduce conflict

View Answer

Answer: a [Reason:] As the name suggests that the conflict is between shift and reduce hence it is called shift reduce conflict.

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

View Answer

Answer: c [Reason:] It occurs when If a state does not know whether it will make a reduction operation using the production rule i or j for a terminal.

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

View Answer

Answer: b [Reason:] There is no terminal before the non-terminal beta.

9. When ß is empty (A -> ß.,a ), the reduction by A-> a is done
a) If next symbol is a terminal
b) Only If the next input symbol is a
c) Only If the next input symbol is A
d) Only if the next input symbol is a

View Answer

Answer: d [Reason:] The next token is considered in this case it’s a.

10. 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 bit different
b) Closure and goto operations work similarly
c) Closure and additive operations work a little bit different
d) Closure and associatively operations work a little bit different

View Answer

Answer: a [Reason:] Closure and goto do work differently in case of LR (0) and LR (1).