Coding | Mcqs | Multiple choice questions | Informative | Computer Science | Engineering | Aptitude | Quants | Verbal

INFEED

Compiler Design Mcq

  • Compiler Design MCQ
  • Compiler translates the source code to

    Both B and C

    4
  • Which of the following groups is/are token together into semantic structures?

    Lexical analyzer

    3
  • Compiler should report the presence of __________ in the source program, in translation process.

    Errors

    3
  • What is the output of lexical analyzer?

    A list of tokens

    2
  • How many parts of compiler are there?

    2

    2
  • Grammar of the programming is checked at _______ phase of compiler.

    Syntax analysis

    2
  • _________ is a process of finding a parse tree for a string of tokens.

    Parsing

    1
  • What is the action of parsing that translates the source program into proper syntactic classes?

    Lexical analysis

    1
  • Compiler can check ________ error.

    Syntax

    2
  • Lexical analysis is about breaking a sequence of characters into

    Tokens

    4
  • ________ is considered as a sequence of characters in a token.

    Lexeme

    3
  • What is the name of the process that determining whether a string of tokens can be generated by a grammar?

    Parsing

    4
  • A _________ is a software utility that translates code written in higher language into a low level language.

    Compiler

    2
  • Task of a compiler is to

    Translate the whole program to machine language

    2
  • In a computer system, number of compilers for a particular programming language may be

    Many

    4
  • Natural language constructs are

    May be Unambiguous or ambiguous

    3
  • Minimum number of states required to accept string with substring 110, where ∑={0,1}

    4

    1
  • Languages of an automata is

    If it is accepted by automata

    1
  • The basic limitation of finite automata is that

    It can’t remember arbitrary large amount of information.

    1
  • Which phase of compiler does NOT use symbol table?

    None of the other options

    4
  • Which phase of compiler is Syntax Analysis?

    Second

    2
  • Output of the syntax analysis is called

    Parse tree

    1
  • Output file of Lex is _____ the input file is Myfile

    Myfile.yy.c

    2
  • A regular expression represents

    Constituent strings of a language

    3
  • When expression sum=3+2 is tokenized then what is the token category of 3

    Integer literal

    3
  • For the Fortran language statement “DO 5 I = 1.25” returns token IDENTIFIER for DO 5 I after looking upto

    .

    3
  • Which of the following are Lexemes?

    All of the mentioned

    4
  • Which of the following is an application of Finite Automaton?

    All of the mentioned

    4
  • The maximum number of transition which can be performed over a state in a DFA? ∑= {a, b, c}

    3

    3
  • NFA, in its name has ’non-deterministic’ because of :

    The choice of path is non-deterministic

    2
  • Consider the following statements about the context free grammar G = {S → SS, S → ab, S → ba, S → Ε} I. G is ambiguous II. G produces all strings with equal number of a’s and b’s III. G can be accepted by a deterministic PDA. Which combination below expresses all the true statements about G?

    I and III only

    2
  • Consider the CFG with {S,A,B) as the non-terminal alphabet, {a,b) as the terminal alphabet, S as the start symbol and the following set of production rules S --> aB S --> bA B --> b A --> a B --> bS A --> aS B --> aBB A --> bAA Which of the following strings is generated by the grammar?

    aabbab

    3
  • S -> aSa|bSb|a|b; The language generated by the above grammar over the alphabet {a,b} is the set of

    All odd length palindromes

    2
  • The grammar {E -> E + E | E * E | id} is

    Ambiguous

    1
  • Which of the following are always unambiguous

    Producing one left-most and one right-most derivation

    1
  • A grammar with production rules { A-> Ba | Cb, B ->CA, C -> c | ε} contains

    Left recursion

    2
  • For the grammar rules {S -> Aa | bB, A -> c |^}, FIRST(S) is

    {a,b, c}

    3
  • A grammar that produces more than one parse tree for some sentence is called as

    Ambiguous

    1
  • _______ is the most general phase structured grammar.

    Context sensitive

    1
  • Find the language generated by S-> aSa | b

    Same number of a's with a 'b' in center

    2
  • Which is not a part of a grammar production ?

    Temporaries

    1
  • The following notation denotes _________ G=(V, T, P, S)

    Context free grammar

    2
  • Derivation produced by a top-down parser is

    Leftmost

    1
  • Derivation produced by a bottom-down parser is

    Rightmost derivation in reverse

    2
  • For top-down parsing left recursion removal is

    Mandatory

    1
  • A grammar is ambiguous if

    More than one left most derivations exist

    2
  • A predictive parser

    Needs backtracking

    1
  • In shift-reduce parsing, handle is at

    Top of the stack

    1
  • Construction of parsing table in which strategies do not need the Follow set?

    Canonical LR and LALR

    2
  • Amount of look ahead in LALR parser is

    1

    1
  • Which of the following pairs is the most powerful

    Canonical LR

    2
  • What is the similarity between LR, LALR and SLR

    Use same algorithm, but different parsing table.

    1
  • In how many types parsing is divided?

    2

    1
  • When the parser starts constructing the parse tree from the start symbol and then tries to transform the start symbol to the input, it is called?

    top-down parsing

    2
  • In __________, if one derivation of a production fails, the syntax analyzer restarts the process using different rules of same production

    Backtracking

    3
  • A form of recursive-descent parsing that does not require any back-tracking is known as?

    predictive parsing

    1
  • Assume that the SLR parser for a grammar G has n1 states and the LALR parser for G has n2 states.

    n1 is necessarily equal to n2

    2
  • The predictive parser puts some constraints on the grammar and accepts only a class of grammar known as LL(k) grammar.

    1
  • Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar?

    None of the above

    4
  • Which of the following derivations does a top-down parser use while parsing an input string?

    Leftmost derivation

    1
  • What is true about Syntax Directed Definitions?

    CFG + Semantic rules = Syntax Directed Definitions

    3
  • Which of the following error is expected to recognize by semantic analyzer?

    All of the above

    4
  • ____________ is a medium to provide semantics to the context-free grammar

    Attribute grammar

    2
  • Semantic analyzer attaches attribute information with AST, which are called?

    Attributed AST

    2
  • Which attributes get values from the attribute values of their child nodes?

    Synthesized attributes

    1
  • Which form of SDT uses both synthesized and inherited attributes with restriction of not taking values from right siblings?

    L-attributed SDT

    4
  • If an SDT uses only synthesized attributes, it is called as?

    S-attributed SDT

    3
  • Which of the following tasks should be performed in semantic analysis?

    All of the above

    4
  • What is meant by compositional semantics?

    Determining the meaning

    1
  • What is true about Attribute Grammar?

    All of the above

    4
  • Errors are

    human made programming mistakes

    2
  • Static errors are detected at

    compile time

    1
  • The output of LR(1) Parser is

    parse tree

    2
  • Dynamic errors are detected at

    run time

    2
  • Error recovery actions in a lexical analyzer is

    panic mode

    1
  • Deleting extra characters is _________ type of error recovery

    panic mode

    1
  • Transposing adjacent character is __________ type of error recovery

    panic mode

    1
  • The output of LL Parser is

    parse tree

    2
  • Inserting missing symbol is ________ type of error recovery.

    panic mode

    1
  • Replacing incorrect character by a correct character is _______ type of error recovery.

    panic mode

    1
  • Writing productions for possible errors is ________ type of error recovery

    error productions

    3
  • Use of global variables to define error occurrence is _________ type of error recovery method.

    global correction

    4
  • A good error handler must

    should recover from each error quickly

    1
  • The output of LR(0) Parser is

    parse tree

    2
  • A good error handler must

    not significantly slow down the processing of the correct program

    2
  • A program without syntax errors but with incorrect output is an example for

    logical error

    2
  • Errors that are caused because of improper understanding of the rules of the programming language is called

    sytax error

    1
  • Errors that are caused because of lack of idea of the solution is called

    logical error

    2
  • A parser detects an error when

    there is no legal move from current configuration

    3
  • which of the following is an example of semantic error?

    type mismatch of operands

    2
  • The load instruction is mostly used to designate a transfer from memory to a processor register known as _______

    Accumulator

    1
  • The specific task storage manager performs

    both 1 and 2

    4
  • When a computer is first turned on or restarted, a special type of absolute loader is executed called

    Boot strap loader

    3
  • Function of the storage assignment is

    all of these

    4
  • A non relocatable program is the one which

    cannot be made to execute in any area of storage other than the one designated for it at the time of its coding or translation

    1
  • A relocatable program form is one which

    can be processed to relocate it to a desired area of memory

    3
  • A self-relocating program is one which

    can itself perform the relocation of its address sensitive portions

    3
  • The best way to compare the different implementations of symbol table is to compare the time required to

    all of these

    4
  • Which of the following known as the text part of a program that does not change at runtime. Its memory requirements are known at the compile time?

    Code

    1
  • A procedure has a start and an end delimiter and everything inside it is called the body of the procedure.

    1
  • In activation record, Which of the following Stores the address of activation record of the caller procedure?

    Control Link

    3
  • Whenever a procedure is executed, its activation record is stored on the stack, also known as?

    Control stack

    2
  • What is true about Formal Parameters?

    These variables are declared in the definition of the called function.

    1
  • For maximum speed of execution of target code , temporary variables be best allocated to

    CPU registers

    3
  • In which mechanism, the calling procedure passes the r-value of actual parameters and the compiler puts that into the called procedure’s activation record?

    Pass by Value

    4
  • In which mechanism, the name of the procedure being called is replaced by its actual body?

    Pass by Name

    2
  • In Directed Acyclic Graph, Leaf nodes represent?

    All of the above

    4
  • __________ are used to keep track of memory locations where the values of identifiers are stored.

    Address descriptor

    2
  • Choose the statement which is incorrect with respect to dynamic memory allocation.

    Execution of the program is faster than that of static memory allocation

    3
  • Dynamic memory allocation is implemented using --------

    Stacks and heaps

    4
  • The memory for variable is allocated before the execution of a program is called------allocation.

    static

    1
  • In--------allocation,a memory can be allocated or deallocated at arbitrary points during its execution.

    program controlled

    4
  • In --------memory allocation, storage is allocated at run-time i.e. memory binding are established and destroyed during the execution of a program.

    dynamic

    1
  • Which of the following is drawback of static allocation strategy?

    All of the above

    4
  • Which field is not present in activation record?

    Register allocation

    2
  • Which is not part of runtime memory subdivision?

    Access link

    4
  • Which language necessarily need heap allocation in the run time environment?

    Those that support recursion

    1
  • Which of the following expression have no l-value?

    3

    3
  • The size field of activation record can be determined at-----------

    Compile time

    2
  • Which of the following symbol table implementation makes efficient use of memory?

    Hash table

    3
  • Which one of the following is FALSE?

    x = 4 ∗ 5 => x = 20 is an example of common subexpression elimination

    4
  • One of the purposes of using intermediate code in compilers is to-----

    increase the chances of reusing the machine-independent code optimizer in other compilers

    3
  • Which one of the following is false?

    There is scope of dead code elimination in this code

    4
  • Consider the grammar rule E → E1 - E2 for arithmetic expressions. The code generated is targeted to a CPU having a single user register. The subtraction operation requires the first operand to be in the register. If E1 and E2 do not have any common sub expression, in order to get the shortest possible code

    E2 should be evaluated first

    2
  • In compiler terminology reduction in strength means-----

    replacing a costly operation by a relatively cheaper one

    4
  • Substitution of values for names (whose values are constants) is done in----------

    Constant folding

    3
  • Which of the following comment about peep-hole optimization is true?

    It is applied to small part of the code and applied repeatedly

    1
  • Which of the following statements about peephole optimization is False?

    It can be applied to the portion of the code that is not contiguous

    4
  • The identification of common sub-expression and replacement of run time computations by compile-time computations is------

    Constant folding

    2
  • ___________ is a tool that depicts the structure of basic blocks, helps to see the flow of values flowing among the basic blocks, and offers optimization too.

    DAG

    1
  • Code optimization is responsibility of--------

    System programmer

    2
  • Dead-code elimination in machine code optimization refersto -----------

    Removal of values that never get used.

    2
  • Which of the following statement is false?

    Flow graph is used to represent DAG.

    1
  • The -------- is the final phase of compiler.

    Code generation

    2
  • Substitution of values for names (whose values are constants) is done in----------

    Constant folding

    3
  • Which of the following comment about peep-hole optimization is true?

    It is applied to small part of the code and applied repeatedly

    1
  • Graph used to represent semantic network is ----

    Directed graph

    2
  • Structure preserving transformations on basic blocks are

    All the above

    4
  • The graph that shows basic blocks and their successor relationship is called

    Flow graph

    2
  • Relocation bits used by relocating loader are specified by

    linker

    2
  • In compiler optimization, operator strength reduction uses mathematical identities to replace slow math operations with faster operations. Which of the following code replacements is an illustration of operator strength reduction ?

    Replace P * 32 by P < < 5

    2
  • Substitution of values for names (whose values are constants like pi= 3.14) is done in

    Constant folding

    3
  • In _______, the bodies of the two loops are merged together to form a single loop provided that they do not make any references to each other.

    Loop jamming

    4
  • Loop unrolling is a code optimization technique:

    That avoids tests at every iteration of the loop.

    1
  • Dead-code elimination in machine code optimization refers to :

    Removal of values that never get used.

    2
  • Some code optimizations are carried out on the intermediate code because

    5
  • x * 2 can be replaced by x << 1 is an example of?

    Strength reduction

    3
  • The__________ are used to keep track of memory locations where the values of identifiers are stored.

    Address descriptor

    2
  • Which of the following is not a form of Intermediate representation?

    Directed cyclic Graph

    3
  • A fragment of code that resides in the loop and computes the same value at each iteration is called a?

    loop-invariant code

    3
  • Question Statement - mandatory (statement delivered to the candidate)

    Correct choice - mandatory
  • A compiler is defined as

    Part of system software

    1
  • Suppose there is a compiler for C language that can generate code for Computer A. Which of the following statements is true

    It can be used only for computers with similar processor and operating system

    3
  • Which of the following data structures may be good if there are frequent search for data items followed by insertion and deletion?

    Hash Table

    4
  • Task of an interpreter is to

    Translate one statement at a time and execute it

    2
  • If an Infinite language is passed to Machine M, the subsidiary which gives a finite solution to the infinite input tape is ______________

    Compiler

    1
  • Finite automata requires minimum _______ number of stacks.

    0

    2
  • A programming language does not allow integer division operation. This is generally detected in the phase of

    Semantic Analysis

    3
  • Which of these is not true about Symbol Table

    Perform the processing of the assembler directives

    3
  • A compiler can check

    Syntax error

    2
  • Error recovery helps to

    Report multiple errors

    1
  • Loops are the major targets for optimization since

    Loop body is repeated to several times

    2
  • For maximum speed of execution of target code , temporary variables be best allocated to

    CPU registers

    3
  • Intermediate code helps in

    Retargeting code

    3
  • The sum of minimum and maximum number of final states for a DFA n states is equal to:

    n+1

    1
  • A Language for which no DFA exist is a________

    Non-Regular Language

    2
  • The maximum sum of in degree and out degree over a state in a DFA can be determined as:______ where ∑= {a, b, c, d}

    depends on the Language

    4
  • A regular expression for accepting strings with exactly one 1 more than 0’s is

    Not Possible

    4
  • Which one of the following languages over the alphabet {0,1} is described by the regular expression: (0+1)*0(0+1)*0(0+1)*

    The set of all strings containing at least two 0’s.

    3
  • Finite automata is an implementation of

    Regular expression

    1
  • The automation which allows transformation to a new state without consuming any input symbols:

    NFA

    1
  • Which of the following conflicts is not possible in shift-reduce parsing

    Shift-shift conflict

    3
  • Which one of the following is true at any valid state in shift-reduce parsing

    Stack contains only viable prefixes

    3
  • For the grammar S → AB | C A → bA | a B → abbS | bS | ε C → bC | ε Follow(A) is

    a , b , $

    2
  • Shift reduce parsers are

    Bottom up Parser

    2
  • In Operator Precedence parsing handle is

    Between <· and ·>

    3
  • By considering the rule B → abbS, which of the precedence relations between a and b can be inferred?

    a ≐ b and b≐ b

    2
  • An operator-precedence parser is a

    All the other options

    4
  • For the grammar rule B → abbS | bS, Firstop(B) equals

    {a , b , S}

    3
  • For the grammar A → BCx | y B → yA | ε C → Ay | x In Predictive Parsing table the cell having multiple entries is

    M[B, y]

    3
  • Bottom up parsing involves

    Both shift reduce and handle pruning

    4
  • For the grammar S' → S S → CC C → cC | d In state 0 of LR(1) parser, an item included is

    C → .cC; c,d

    3
  • For the grammar S' → S S → CC C → cC | d In state 0 of LR(1) parser, an item included is

    C → .d; c,d

    3
  • In SLR parsing to get a shift-reduce conflict for state I on terminal symbol ‘a’,

    A -> α.β with First(β) containing ‘a’ should be in I and A ->δ. be in I with Follow(A) having ‘a’

    3
  • In state I we have the items A -> α. and B -> δ., First(A), Follow(A) and Follow(B) contains the symbol ‘a’. This leads to

    Reduce – reduce conflict

    2
  • Between SLR, Canonical LR and LALR, which have same number of states

    SLR and LALR

    1
  • In SLR parsing for the grammar E' → E E → aEbE | bEaE | ε In state 0, for inputs 'a' and 'b'

    Both will have shift-reduce conflict

    1
  • In SLR parsing for the grammar S → B | SabS B → bB | ε In state 0, for inputs 'a' and 'b'

    Only 'a' will have shift-reduce conflict

    2
  • A can be A-> derivable if and only if __________

    A-> A is actually a production

    1
  • The context free languages are closed under:

    Kleene

    3
  • Which of the following strings do not belong the given regular expression? (a)*(a+cba)

    acbacba

    4
  • Error handling and recovery is done by _________ phase

    semantic

    3
  • Error recovery is

    resume program execution after taking corrective actions

    2
  • Which is not a error recovery strategies in syntax analysis phase

    error correction

    3
  • Error recovery is not possible in _____ type of grammar

    None of the mentioned

    4
  • What is the index number of the last element of an array with 29 elements?

    28

    2
  • What is meaning of the following? int *ptr[20];

    Array of integer pointer of size 20

    3
  • Synthesized attribute can be easily simulated by a

    LR grammar

    3
  • Intermediate code generation phase gets input from

    Semantic analyzer

    3
  • Which is not true about syntax and semantic parts of a computer language?

    None of the mentioned

    4
  • Intermediate code helps in

    Retargeting code

    3
  • Which form of SDT uses both synthesized and inherited attributes with restriction of not taking values from right siblings?

    L-attributed SDT

    4
  • What value does the variable z have after ALL of the code above executes? int x; int y; int z; x=3; y=4; z = ++x * y++;

    16

    3
  • What is the max no. of dimensions an array may have?

    No limit

    4
  • An intermediate code form is

    All of these

    4
  • Type checking is normally done during-----------

    Syntax directed translation

    3
  • Three address code generated temporary name are made up for the __________ of the syntax tree.

    Interior node

    1
  • Expressions that govern the flow of control that may be Boolean expressions containing_________ and _________ operators.

    Relational & logical

    2
  • Listing pointers to triples, rather than listing triples themselves is implementation of

    Indirect Triple

    3
  • _____________creates a new symbol table & returns a pointer to the new table.

    mktable(previous)

    1
  • ___________creates a new entry for procedure name in the symbol table pointed to by table

    enterproc(table, name, new table)

    4
  • Consider the following intermediate program in three address code p = a - b q = p * c p = u * v q = p + q Which one of the following corresponds to a static single assignment form of the above code?

    p3 = a - b q4 = p3 * c p4 = u * c q5 = p4 + q4

    2
  • In which storage allocation strategy size is required at compiler time?

    Static allocation

    1
  • Which of the following fields are of activation record?

    All of the above

    4
  • A _______tree is used to depict the way control enters and leaves activations

    Activation

    1
  • In activation tree each node represent---------

    Activation of a procedure

    2
  • In activation tree each root represent--------

    Activation of main program

    1
  • In activation trees the node for a is the parent of node for b if and only if--------

    If control flows from activation of a to b

    2
  • In activation trees, the node for a is to the left of node for b if and only if--

    If lifetime of a occurs before lifetime of b

    1
  • Flow of control in a program corresponds to which traversal of activation tree?

    Depth first traversal

    1
  • A(n)--------can be used to keep track of live procedure activations

    Control stack

    3
  • If the occurrence of name in procedure is in the scope of declaration within the procedure then it is said to be------

    Local

    1
  • Information needed by execution of a procedure is managed using a contiguous block of storage called-----

    Both A and B

    3
  • In activation record, optional control link points to------

    Activation record of caller

    1
  • The field of actual parameter in activation record is used by which procedure-----------

    Called procedure

    2
  • Consider an assignment statement like a[i]:=a[j] then here a[i] represent------and a[j] represent-------

    Storage location and value

    2
  • In which allocation, names are bound to storage as program is compiled-----

    Stack

    3
  • Call by reference also called as----

    Both A and B

    3
  • Triple is a record structure with three fields-------

    op, arg1, arg2

    1
  • One of the purposes of using intermediate code in compilers is to---------

    increase the chances of reusing the machine-independent code optimizer in other compilers

    3
  • Which one of the following is not type of intermediate code representations?

    Preorder

    3
  • Consider the intermediate code given below: 1. i = 1 2. j = 1 3. t1 = 5 * i 4. t2 = t1 + j 5. t3 = 4 * t2 6. t4 = t3 7. a[t4] = –1 8. j = j + 1 9. if j ≤ 5 goto(3) 10. i = i + 1 11. if i < 5 goto(2) The number of nodes and edges in the control-flow-graph constructed for the above code, respectively, are------

    6 and 7

    2
  • Consider the following source code : c = a + b d = c c = c – e a = d – e b = b * e b = d/b Which of the following is correct optimization of given code?

    None of the above

    4
  • Consider the code segment int i, j, x, y, m, n; n=20; for (i = 0, i < n; i++) { for (j = 0; j < n; j++) { if (i % 2) { x + = ((4*j) + 5*i); y += (7 + 4*j); } } } m = x + y; Which one of the following is false.

    There is scope of dead code elimination in this code

    4
  • Peephole optimization is form of------

    Local optimization

    2
  • Consider the following intermediate program in three address code p = a - b q = p * c p = u * v q = p + q Which one of the following corresponds to a static single assignment form of the above code?

    p3 = a - b q4 = p3 * c p4 = u * c q5 = p4 + q4

    2
  • Some code optimizations are carried out on the intermediate code because------

    They enhance the portability of the compiler to other target processors

    1
  • In compiler terminology reduction in strength means-----

    replacing a costly operation by a relatively cheaper one

    4
  • 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 CODES: A B C D

    2 4 1 3

    3
  • Consider the following C code segment.for (i = 0, i<n; i++) { for (j=0; j<n; j++) { if (i%2) { x += (4*j + 5*i); y += (7 + 4*j); } }} Which one of the following is false?

    There is scope of dead code elimination in this code

    4
  • The following code is an example of? void add_ten(int x) { return x + 10; printf(""value of x is %d"", x); }

    Unreachable code

    2
  • A variable is called an _________ variable if its value is altered within the loop by a loop-invariant value.

    induction

    2
  • Dead code plays no role in any program operation and therefore it can simply be eliminated.

    1
  • In analyzing the compilation of PL/I program, the term Machine independent optimization is assosiated with

    creation of more optical matrix

    1
  • The compiler can make use of memory hierarchy and CPU registers.

    1
  • A compiler for a high-level language that runs on one machine and produces code for a different machine is called

    cross compiler

    3
  • What will be error here? 7 = x + y;

    l-value error

    1
  • The location of memory (address) where an expression is stored is known?

    l-value error

    2
  • A pictorial representation of the value computed by each statement in the basic block is

    DAG

    2
  • In a two pass assembler the object code generation is done during the ?

    Second pass

    2
  • Yet Another Compiler’s Compiler is a tool for

    Syntax analysis

    4
  • Question Statement - mandatory (statement delivered to the candidate)

    Correct choice - mandatory
  • Compiler translates the source code to

    Both B and C

    4
  • Which of the following groups is/are token together into semantic structures?

    Lexical analyzer

    3
  • Compiler should report the presence of __________ in the source program, in translation process.

    Errors

    3
  • What is the output of lexical analyzer?

    A list of tokens

    2
  • How many parts of compiler are there?

    2

    2
  • Grammar of the programming is checked at _______ phase of compiler.

    Syntax analysis

    2
  • _________ is a process of finding a parse tree for a string of tokens.

    Parsing

    1
  • What is the action of parsing that translates the source program into proper syntactic classes?

    Lexical analysis

    1
  • Compiler can check ________ error.

    Syntax

    2
  • Lexical analysis is about breaking a sequence of characters into

    Tokens

    4
  • ________ is considered as a sequence of characters in a token.

    Lexeme

    3
  • What is the name of the process that determining whether a string of tokens can be generated by a grammar?

    Parsing

    4
  • A _________ is a software utility that translates code written in higher language into a low level language.

    Compiler

    2
  • Task of a compiler is to

    Translate the whole program to machine language

    2
  • In a computer system, number of compilers for a particular programming language may be

    Many

    4
  • Natural language constructs are

    May be Unambiguous or ambiguous

    3
  • Minimum number of states required to accept string with substring 110, where ∑={0,1}

    4

    1
  • Languages of an automata is

    If it is accepted by automata

    1
  • The basic limitation of finite automata is that

    It can’t remember arbitrary large amount of information.

    1
  • Which phase of compiler does NOT use symbol table?

    None of the other options

    4
  • Which phase of compiler is Syntax Analysis?

    Second

    2
  • Output of the syntax analysis is called

    Parse tree

    1
  • Output file of Lex is _____ the input file is Myfile

    Myfile.yy.c

    2
  • A regular expression represents

    Constituent strings of a language

    3
  • When expression sum=3+2 is tokenized then what is the token category of 3

    Integer literal

    3
  • For the Fortran language statement “DO 5 I = 1.25” returns token IDENTIFIER for DO 5 I after looking upto

    .

    3
  • Which of the following are Lexemes?

    All of the mentioned

    4
  • Which of the following is an application of Finite Automaton?

    All of the mentioned

    4
  • The maximum number of transition which can be performed over a state in a DFA? ∑= {a, b, c}

    3

    3
  • NFA, in its name has ’non-deterministic’ because of :

    The choice of path is non-deterministic

    2
  • Consider the following statements about the context free grammar G = {S → SS, S → ab, S → ba, S → Ε} I. G is ambiguous II. G produces all strings with equal number of a’s and b’s III. G can be accepted by a deterministic PDA. Which combination below expresses all the true statements about G?

    I and III only

    2
  • Consider the CFG with {S,A,B) as the non-terminal alphabet, {a,b) as the terminal alphabet, S as the start symbol and the following set of production rules S --> aB S --> bA B --> b A --> a B --> bS A --> aS B --> aBB A --> bAA Which of the following strings is generated by the grammar?

    aabbab

    3
  • S -> aSa|bSb|a|b; The language generated by the above grammar over the alphabet {a,b} is the set of

    All odd length palindromes

    2
  • The grammar {E -> E + E | E * E | id} is

    Ambiguous

    1
  • Which of the following are always unambiguous

    Producing one left-most and one right-most derivation

    1
  • A grammar with production rules { A-> Ba | Cb, B ->CA, C -> c | ε} contains

    Left recursion

    2
  • For the grammar rules {S -> Aa | bB, A -> c |^}, FIRST(S) is

    {a,b, c}

    3
  • A grammar that produces more than one parse tree for some sentence is called as

    Ambiguous

    1
  • _______ is the most general phase structured grammar.

    Context sensitive

    1
  • Find the language generated by S-> aSa | b

    Same number of a's with a 'b' in center

    2
  • Which is not a part of a grammar production ?

    Temporaries

    1
  • The following notation denotes _________ G=(V, T, P, S)

    Context free grammar

    2
  • Derivation produced by a top-down parser is

    Leftmost

    1
  • Derivation produced by a bottom-down parser is

    Rightmost derivation in reverse

    2
  • For top-down parsing left recursion removal is

    Mandatory

    1
  • A grammar is ambiguous if

    More than one left most derivations exist

    2
  • A predictive parser

    Needs backtracking

    1
  • In shift-reduce parsing, handle is at

    Top of the stack

    1
  • Construction of parsing table in which strategies do not need the Follow set?

    Canonical LR and LALR

    2
  • Amount of look ahead in LALR parser is

    1

    1
  • Which of the following pairs is the most powerful

    Canonical LR

    2
  • What is the similarity between LR, LALR and SLR

    Use same algorithm, but different parsing table.

    1
  • In how many types parsing is divided?

    2

    1
  • When the parser starts constructing the parse tree from the start symbol and then tries to transform the start symbol to the input, it is called?

    top-down parsing

    2
  • In __________, if one derivation of a production fails, the syntax analyzer restarts the process using different rules of same production

    Backtracking

    3
  • A form of recursive-descent parsing that does not require any back-tracking is known as?

    predictive parsing

    1
  • Assume that the SLR parser for a grammar G has n1 states and the LALR parser for G has n2 states.

    n1 is necessarily equal to n2

    2
  • The predictive parser puts some constraints on the grammar and accepts only a class of grammar known as LL(k) grammar.

    1
  • Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar?

    None of the above

    4
  • Which of the following derivations does a top-down parser use while parsing an input string?

    Leftmost derivation

    1
  • What is true about Syntax Directed Definitions?

    CFG + Semantic rules = Syntax Directed Definitions

    3
  • Which of the following error is expected to recognize by semantic analyzer?

    All of the above

    4
  • ____________ is a medium to provide semantics to the context-free grammar

    Attribute grammar

    2
  • Semantic analyzer attaches attribute information with AST, which are called?

    Attributed AST

    2
  • Which attributes get values from the attribute values of their child nodes?

    Synthesized attributes

    1
  • Which form of SDT uses both synthesized and inherited attributes with restriction of not taking values from right siblings?

    L-attributed SDT

    4
  • If an SDT uses only synthesized attributes, it is called as?

    S-attributed SDT

    3
  • Which of the following tasks should be performed in semantic analysis?

    All of the above

    4
  • What is meant by compositional semantics?

    Determining the meaning

    1
  • What is true about Attribute Grammar?

    All of the above

    4
  • Errors are

    human made programming mistakes

    2
  • Static errors are detected at

    compile time

    1
  • The output of LR(1) Parser is

    parse tree

    2
  • Dynamic errors are detected at

    run time

    2
  • Error recovery actions in a lexical analyzer is

    panic mode

    1
  • Deleting extra characters is _________ type of error recovery

    panic mode

    1
  • Transposing adjacent character is __________ type of error recovery

    panic mode

    1
  • The output of LL Parser is

    parse tree

    2
  • Inserting missing symbol is ________ type of error recovery.

    panic mode

    1
  • Replacing incorrect character by a correct character is _______ type of error recovery.

    panic mode

    1
  • Writing productions for possible errors is ________ type of error recovery

    error productions

    3
  • Use of global variables to define error occurrence is _________ type of error recovery method.

    global correction

    4
  • A good error handler must

    should recover from each error quickly

    1
  • The output of LR(0) Parser is

    parse tree

    2
  • A good error handler must

    not significantly slow down the processing of the correct program

    2
  • A program without syntax errors but with incorrect output is an example for

    logical error

    2
  • Errors that are caused because of improper understanding of the rules of the programming language is called

    sytax error

    1
  • Errors that are caused because of lack of idea of the solution is called

    logical error

    2
  • A parser detects an error when

    there is no legal move from current configuration

    3
  • which of the following is an example of semantic error?

    type mismatch of operands

    2
  • The load instruction is mostly used to designate a transfer from memory to a processor register known as _______

    Accumulator

    1
  • The specific task storage manager performs

    both 1 and 2

    4
  • When a computer is first turned on or restarted, a special type of absolute loader is executed called

    Boot strap loader

    3
  • Function of the storage assignment is

    all of these

    4
  • A non relocatable program is the one which

    cannot be made to execute in any area of storage other than the one designated for it at the time of its coding or translation

    1
  • A relocatable program form is one which

    can be processed to relocate it to a desired area of memory

    3
  • A self-relocating program is one which

    can itself perform the relocation of its address sensitive portions

    3
  • The best way to compare the different implementations of symbol table is to compare the time required to

    all of these

    4
  • Which of the following known as the text part of a program that does not change at runtime. Its memory requirements are known at the compile time?

    Code

    1
  • A procedure has a start and an end delimiter and everything inside it is called the body of the procedure.

    1
  • In activation record, Which of the following Stores the address of activation record of the caller procedure?

    Control Link

    3
  • Whenever a procedure is executed, its activation record is stored on the stack, also known as?

    Control stack

    2
  • What is true about Formal Parameters?

    These variables are declared in the definition of the called function.

    1
  • For maximum speed of execution of target code , temporary variables be best allocated to

    CPU registers

    3
  • In which mechanism, the calling procedure passes the r-value of actual parameters and the compiler puts that into the called procedure’s activation record?

    Pass by Value

    4
  • In which mechanism, the name of the procedure being called is replaced by its actual body?

    Pass by Name

    2
  • In Directed Acyclic Graph, Leaf nodes represent?

    All of the above

    4
  • __________ are used to keep track of memory locations where the values of identifiers are stored.

    Address descriptor

    2
  • Choose the statement which is incorrect with respect to dynamic memory allocation.

    Execution of the program is faster than that of static memory allocation

    3
  • Dynamic memory allocation is implemented using --------

    Stacks and heaps

    4
  • The memory for variable is allocated before the execution of a program is called------allocation.

    static

    1
  • In--------allocation,a memory can be allocated or deallocated at arbitrary points during its execution.

    program controlled

    4
  • In --------memory allocation, storage is allocated at run-time i.e. memory binding are established and destroyed during the execution of a program.

    dynamic

    1
  • Which of the following is drawback of static allocation strategy?

    All of the above

    4
  • Which field is not present in activation record?

    Register allocation

    2
  • Which is not part of runtime memory subdivision?

    Access link

    4
  • Which language necessarily need heap allocation in the run time environment?

    Those that support recursion

    1
  • Which of the following expression have no l-value?

    3

    3
  • The size field of activation record can be determined at-----------

    Compile time

    2
  • Which of the following symbol table implementation makes efficient use of memory?

    Hash table

    3
  • Which one of the following is FALSE?

    x = 4 ∗ 5 => x = 20 is an example of common subexpression elimination

    4
  • One of the purposes of using intermediate code in compilers is to-----

    increase the chances of reusing the machine-independent code optimizer in other compilers

    3
  • Which one of the following is false?

    There is scope of dead code elimination in this code

    4
  • Consider the grammar rule E → E1 - E2 for arithmetic expressions. The code generated is targeted to a CPU having a single user register. The subtraction operation requires the first operand to be in the register. If E1 and E2 do not have any common sub expression, in order to get the shortest possible code

    E2 should be evaluated first

    2
  • In compiler terminology reduction in strength means-----

    replacing a costly operation by a relatively cheaper one

    4
  • Substitution of values for names (whose values are constants) is done in----------

    Constant folding

    3
  • Which of the following comment about peep-hole optimization is true?

    It is applied to small part of the code and applied repeatedly

    1
  • Which of the following statements about peephole optimization is False?

    It can be applied to the portion of the code that is not contiguous

    4
  • The identification of common sub-expression and replacement of run time computations by compile-time computations is------

    Constant folding

    2
  • ___________ is a tool that depicts the structure of basic blocks, helps to see the flow of values flowing among the basic blocks, and offers optimization too.

    DAG

    1
  • Code optimization is responsibility of--------

    System programmer

    2
  • Dead-code elimination in machine code optimization refersto -----------

    Removal of values that never get used.

    2
  • Which of the following statement is false?

    Flow graph is used to represent DAG.

    1
  • The -------- is the final phase of compiler.

    Code generation

    2
  • Substitution of values for names (whose values are constants) is done in----------

    Constant folding

    3
  • Which of the following comment about peep-hole optimization is true?

    It is applied to small part of the code and applied repeatedly

    1
  • Graph used to represent semantic network is ----

    Directed graph

    2
  • Structure preserving transformations on basic blocks are

    All the above

    4
  • The graph that shows basic blocks and their successor relationship is called

    Flow graph

    2
  • Relocation bits used by relocating loader are specified by

    linker

    2
  • In compiler optimization, operator strength reduction uses mathematical identities to replace slow math operations with faster operations. Which of the following code replacements is an illustration of operator strength reduction ?

    Replace P * 32 by P < < 5

    2
  • Substitution of values for names (whose values are constants like pi= 3.14) is done in

    Constant folding

    3
  • In _______, the bodies of the two loops are merged together to form a single loop provided that they do not make any references to each other.

    Loop jamming

    4
  • Loop unrolling is a code optimization technique:

    That avoids tests at every iteration of the loop.

    1
  • Dead-code elimination in machine code optimization refers to :

    Removal of values that never get used.

    2
  • Some code optimizations are carried out on the intermediate code because

    5
  • x * 2 can be replaced by x << 1 is an example of?

    Strength reduction

    3
  • The__________ are used to keep track of memory locations where the values of identifiers are stored.

    Address descriptor

    2
  • Which of the following is not a form of Intermediate representation?

    Directed cyclic Graph

    3
  • A fragment of code that resides in the loop and computes the same value at each iteration is called a?

    loop-invariant code

    3
  • Question Statement - mandatory (statement delivered to the candidate)

    Correct choice - mandatory
  • A compiler is defined as

    Part of system software

    1
  • Suppose there is a compiler for C language that can generate code for Computer A. Which of the following statements is true

    It can be used only for computers with similar processor and operating system

    3
  • Which of the following data structures may be good if there are frequent search for data items followed by insertion and deletion?

    Hash Table

    4
  • Task of an interpreter is to

    Translate one statement at a time and execute it

    2
  • If an Infinite language is passed to Machine M, the subsidiary which gives a finite solution to the infinite input tape is ______________

    Compiler

    1
  • Finite automata requires minimum _______ number of stacks.

    0

    2
  • A programming language does not allow integer division operation. This is generally detected in the phase of

    Semantic Analysis

    3
  • Which of these is not true about Symbol Table

    Perform the processing of the assembler directives

    3
  • A compiler can check

    Syntax error

    2
  • Error recovery helps to

    Report multiple errors

    1
  • Loops are the major targets for optimization since

    Loop body is repeated to several times

    2
  • For maximum speed of execution of target code , temporary variables be best allocated to

    CPU registers

    3
  • Intermediate code helps in

    Retargeting code

    3
  • The sum of minimum and maximum number of final states for a DFA n states is equal to:

    n+1

    1
  • A Language for which no DFA exist is a________

    Non-Regular Language

    2
  • The maximum sum of in degree and out degree over a state in a DFA can be determined as:______ where ∑= {a, b, c, d}

    depends on the Language

    4
  • A regular expression for accepting strings with exactly one 1 more than 0’s is

    Not Possible

    4
  • Which one of the following languages over the alphabet {0,1} is described by the regular expression: (0+1)*0(0+1)*0(0+1)*

    The set of all strings containing at least two 0’s.

    3
  • Finite automata is an implementation of

    Regular expression

    1
  • The automation which allows transformation to a new state without consuming any input symbols:

    NFA

    1
  • Which of the following conflicts is not possible in shift-reduce parsing

    Shift-shift conflict

    3
  • Which one of the following is true at any valid state in shift-reduce parsing

    Stack contains only viable prefixes

    3
  • For the grammar S → AB | C A → bA | a B → abbS | bS | ε C → bC | ε Follow(A) is

    a , b , $

    2
  • Shift reduce parsers are

    Bottom up Parser

    2
  • In Operator Precedence parsing handle is

    Between <· and ·>

    3
  • By considering the rule B → abbS, which of the precedence relations between a and b can be inferred?

    a ≐ b and b≐ b

    2
  • An operator-precedence parser is a

    All the other options

    4
  • For the grammar rule B → abbS | bS, Firstop(B) equals

    {a , b , S}

    3
  • For the grammar A → BCx | y B → yA | ε C → Ay | x In Predictive Parsing table the cell having multiple entries is

    M[B, y]

    3
  • Bottom up parsing involves

    Both shift reduce and handle pruning

    4
  • For the grammar S' → S S → CC C → cC | d In state 0 of LR(1) parser, an item included is

    C → .cC; c,d

    3
  • For the grammar S' → S S → CC C → cC | d In state 0 of LR(1) parser, an item included is

    C → .d; c,d

    3
  • In SLR parsing to get a shift-reduce conflict for state I on terminal symbol ‘a’,

    A -> α.β with First(β) containing ‘a’ should be in I and A ->δ. be in I with Follow(A) having ‘a’

    3
  • In state I we have the items A -> α. and B -> δ., First(A), Follow(A) and Follow(B) contains the symbol ‘a’. This leads to

    Reduce – reduce conflict

    2
  • Between SLR, Canonical LR and LALR, which have same number of states

    SLR and LALR

    1
  • In SLR parsing for the grammar E' → E E → aEbE | bEaE | ε In state 0, for inputs 'a' and 'b'

    Both will have shift-reduce conflict

    1
  • In SLR parsing for the grammar S → B | SabS B → bB | ε In state 0, for inputs 'a' and 'b'

    Only 'a' will have shift-reduce conflict

    2
  • A can be A-> derivable if and only if __________

    A-> A is actually a production

    1
  • The context free languages are closed under:

    Kleene

    3
  • Which of the following strings do not belong the given regular expression? (a)*(a+cba)

    acbacba

    4
  • Error handling and recovery is done by _________ phase

    semantic

    3
  • Error recovery is

    resume program execution after taking corrective actions

    2
  • Which is not a error recovery strategies in syntax analysis phase

    error correction

    3
  • Error recovery is not possible in _____ type of grammar

    None of the mentioned

    4
  • What is the index number of the last element of an array with 29 elements?

    28

    2
  • What is meaning of the following? int *ptr[20];

    Array of integer pointer of size 20

    3
  • Synthesized attribute can be easily simulated by a

    LR grammar

    3
  • Intermediate code generation phase gets input from

    Semantic analyzer

    3
  • Which is not true about syntax and semantic parts of a computer language?

    None of the mentioned

    4
  • Intermediate code helps in

    Retargeting code

    3
  • Which form of SDT uses both synthesized and inherited attributes with restriction of not taking values from right siblings?

    L-attributed SDT

    4
  • What value does the variable z have after ALL of the code above executes? int x; int y; int z; x=3; y=4; z = ++x * y++;

    16

    3
  • What is the max no. of dimensions an array may have?

    No limit

    4
  • An intermediate code form is

    All of these

    4
  • Type checking is normally done during-----------

    Syntax directed translation

    3
  • Three address code generated temporary name are made up for the __________ of the syntax tree.

    Interior node

    1
  • Expressions that govern the flow of control that may be Boolean expressions containing_________ and _________ operators.

    Relational & logical

    2
  • Listing pointers to triples, rather than listing triples themselves is implementation of

    Indirect Triple

    3
  • _____________creates a new symbol table & returns a pointer to the new table.

    mktable(previous)

    1
  • ___________creates a new entry for procedure name in the symbol table pointed to by table

    enterproc(table, name, new table)

    4
  • Consider the following intermediate program in three address code p = a - b q = p * c p = u * v q = p + q Which one of the following corresponds to a static single assignment form of the above code?

    p3 = a - b q4 = p3 * c p4 = u * c q5 = p4 + q4

    2
  • In which storage allocation strategy size is required at compiler time?

    Static allocation

    1
  • Which of the following fields are of activation record?

    All of the above

    4
  • A _______tree is used to depict the way control enters and leaves activations

    Activation

    1
  • In activation tree each node represent---------

    Activation of a procedure

    2
  • In activation tree each root represent--------

    Activation of main program

    1
  • In activation trees the node for a is the parent of node for b if and only if--------

    If control flows from activation of a to b

    2
  • In activation trees, the node for a is to the left of node for b if and only if--

    If lifetime of a occurs before lifetime of b

    1
  • Flow of control in a program corresponds to which traversal of activation tree?

    Depth first traversal

    1
  • A(n)--------can be used to keep track of live procedure activations

    Control stack

    3
  • If the occurrence of name in procedure is in the scope of declaration within the procedure then it is said to be------

    Local

    1
  • Information needed by execution of a procedure is managed using a contiguous block of storage called-----

    Both A and B

    3
  • In activation record, optional control link points to------

    Activation record of caller

    1
  • The field of actual parameter in activation record is used by which procedure-----------

    Called procedure

    2
  • Consider an assignment statement like a[i]:=a[j] then here a[i] represent------and a[j] represent-------

    Storage location and value

    2
  • In which allocation, names are bound to storage as program is compiled-----

    Stack

    3
  • Call by reference also called as----

    Both A and B

    3
  • Triple is a record structure with three fields-------

    op, arg1, arg2

    1
  • One of the purposes of using intermediate code in compilers is to---------

    increase the chances of reusing the machine-independent code optimizer in other compilers

    3
  • Which one of the following is not type of intermediate code representations?

    Preorder

    3
  • Consider the intermediate code given below: 1. i = 1 2. j = 1 3. t1 = 5 * i 4. t2 = t1 + j 5. t3 = 4 * t2 6. t4 = t3 7. a[t4] = –1 8. j = j + 1 9. if j ≤ 5 goto(3) 10. i = i + 1 11. if i < 5 goto(2) The number of nodes and edges in the control-flow-graph constructed for the above code, respectively, are------

    6 and 7

    2
  • Consider the following source code : c = a + b d = c c = c – e a = d – e b = b * e b = d/b Which of the following is correct optimization of given code?

    None of the above

    4
  • Consider the code segment int i, j, x, y, m, n; n=20; for (i = 0, i < n; i++) { for (j = 0; j < n; j++) { if (i % 2) { x + = ((4*j) + 5*i); y += (7 + 4*j); } } } m = x + y; Which one of the following is false.

    There is scope of dead code elimination in this code

    4
  • Peephole optimization is form of------

    Local optimization

    2
  • Consider the following intermediate program in three address code p = a - b q = p * c p = u * v q = p + q Which one of the following corresponds to a static single assignment form of the above code?

    p3 = a - b q4 = p3 * c p4 = u * c q5 = p4 + q4

    2
  • Some code optimizations are carried out on the intermediate code because------

    They enhance the portability of the compiler to other target processors

    1
  • In compiler terminology reduction in strength means-----

    replacing a costly operation by a relatively cheaper one

    4
  • 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 CODES: A B C D

    2 4 1 3

    3
  • Consider the following C code segment.for (i = 0, i<n; i++) { for (j=0; j<n; j++) { if (i%2) { x += (4*j + 5*i); y += (7 + 4*j); } }} Which one of the following is false?

    There is scope of dead code elimination in this code

    4
  • The following code is an example of? void add_ten(int x) { return x + 10; printf(""value of x is %d"", x); }

    Unreachable code

    2
  • A variable is called an _________ variable if its value is altered within the loop by a loop-invariant value.

    induction

    2
  • Dead code plays no role in any program operation and therefore it can simply be eliminated.

    1
  • In analyzing the compilation of PL/I program, the term Machine independent optimization is assosiated with

    creation of more optical matrix

    1
  • The compiler can make use of memory hierarchy and CPU registers.

    1
  • A compiler for a high-level language that runs on one machine and produces code for a different machine is called

    cross compiler

    3
  • What will be error here? 7 = x + y;

    l-value error

    1
  • The location of memory (address) where an expression is stored is known?

    l-value error

    2
  • A pictorial representation of the value computed by each statement in the basic block is

    DAG

    2
  • In a two pass assembler the object code generation is done during the ?

    Second pass

    2
  • Yet Another Compiler’s Compiler is a tool for

    Syntax analysis option:4




Post a Comment

Previous Post Next Post