100% found this document useful (1 vote)
4K views16 pages

Compiler Construction MCQ

The document contains a question bank with multiple choice questions related to compiler construction. 1) It has 42 questions about various topics in compilers including lexical analysis, syntax analysis, semantic analysis, intermediate code generation, code optimization and parsing. 2) The questions test knowledge of topics like grammars (LL, LR, LALR, SLR etc.), parsing techniques (top-down, bottom-up), symbol tables, intermediate code representations (3-address code, quadruples) and code optimization.

Uploaded by

Saad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
4K views16 pages

Compiler Construction MCQ

The document contains a question bank with multiple choice questions related to compiler construction. 1) It has 42 questions about various topics in compilers including lexical analysis, syntax analysis, semantic analysis, intermediate code generation, code optimization and parsing. 2) The questions test knowledge of topics like grammars (LL, LR, LALR, SLR etc.), parsing techniques (top-down, bottom-up), symbol tables, intermediate code representations (3-address code, quadruples) and code optimization.

Uploaded by

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

A.T.S.S.

’s
College of Business Studies and Computer Applications
Chinchwad, Pune 19
(Affiliated to Savitribai Phule Pune University, Recognized by Govt. of Maharashtra , Accredited by NAAC)
Academic Year 2019 – 20
MCQ Question Bank
Class:-T.Y.Bsc(CS) Subject :-Compiler Construction

1. Three address code involves


a) Exactly 3 address
b) At most most 3 address
c) No unary operators
d) None of these
Answer : d

2. In operator precedence parsing , precedence relations are denoted by


a) For all pair of non terminals
b) For all pair of terminals
c) To delimit the handle
d) Only for a certain pair of terminals
Answer : d

3. Relocating bits used by relocating loader are specified by


a) Relocating loader itself
b) Linker
c) Assembler
d) Macro processor
Answer : b

4. Synthesized attribute can be easily simulated by a


a) LL grammar
b) Ambiguous grammar
c) LR grammar
d) None of the above
Answer : c

5. The output of a lexical analyzer is


a) Machine code
b) Intermediate code
c) A stream of tokens
d) A parse tree
Answer : c

6. Running time of a program depends on


a) The way the registers and addressing modes are used
b) The order in which computations are performed
c) The usage of machine idioms
d) All of these
Answer : d

7. Task of the lexical analysis


a) To parse the source program into the basic elements or tokens of the language
b) To build a literal table and an identifier table
c) To build a uniform symbol table
d) All of these
Answer : d

8. Shift reduce parsers are


a) Top down parser
b) Bottom up parser
c) May be top down or bottom up parser
d) None of the above
Answer : b

9. The linker
a) is similar to interpreter
b) uses source code as its input
c) is required to create a load module
d) none of the above
Answer : c

10. A grammar that produces more than one parse tree for some sentence is called
a) Ambiguous
b) Unambiguous
c) Regular
d) None of these
Answer : a

11. In an absolute loading scheme which loader function is accomplished by assembler ?


a) re-allocation
b) allocation
c) linking
d) loading
Answer : a
12. Intermediate code generation phase gets input from
a) Lexical analyzer
b) Syntax analyzer
c) Semantic analyzer
d) Error handling
Answer : c

13. We can optimize code by


a) Dead code elimination
b) Common subprograms
c) Copy intermediate loop
d) Loop declaration
Answer : a

14. Code can be optimized at


a) Source from user
b) Target code
c) Intermediate code
d) All of the above
Answer : a

15. YACC builds up


a) SLR parsing table
b) Canonical LR parsing table
c) LALR parsing table
d) None of the above
Answer : c

16. A top down parser generates


a) Right most derivation
b) Right most derivation in reverse
c) Left most derivation
d) Left most derivation in reverse
Answer : c

17. In an absolute loading scheme, which loader function is accomplished by a loader ?


a) Re-allocation
b) Allocation
c) Linking
d) Loading
Answer : d
18. The lexical analyzer takes_________as input and produces a stream of_______as output.
a) Source program,tokens
b) Token,source program
c) Either A and B
d) None of the above
Answer : a

19. ___________is a graph representation of a derivation


a) The parse tree
b) The oct tree
c) The binary tree
d) None of the above
Answer : a

20. Which of the following is used for grouping of characters into tokens?
a) Parser
b) Code optimization
c) Code generator
d) Lexical analyzer
Answer : d

21. A compiler that runs on one machine and produces code for a different machine is called
a) Cross compilation
b) One pass compilation
c) Two pass compilation
d) None of the above
Answer : a

22. Which of the following is not an intermediate code form?

a) Postfix notation
b) Syntax trees
c) Three address codes
d) Quadruples
Answer : d

23. Grammar of the programming is checked at ________ phase of compiler.


a) semantic analysis
b) code generation
c) syntax analysis
d) code optimization
Answer : c
24. LR stands for
a) Left to right
b) Left to right reduction
c) Right to left
d) Left to right and right most derivation in reverse
Answer: d

25. Which of the following parser is most powerful?


a) Operator precedence
b) Canonical LR
c) LALR
d) SLR
Answer : b

26. Syntax directed translation scheme is desirable because

a) It is based on the syntax


b) Its description is independent of any implementation
c) It is easy to modify
d) All of these
Answer : c

27. A bottom up parser generates


a) Right most derivation
b) Rightmost derivation in reverse
c) Leftmost derivation
d) Leftmost derivation in reverse
Answer: b
Explanation: This corresponds to starting at the leaves of the parse tree also known as
shift-reduce parsing.

28. grammar that produces more than one parse tree for some sentence is called
a) Ambiguous
b) Unambiguous
c) Regular
d) None of the mentioned
Answer: a
Explanation: ambiguous grammar has more than one parse tree.

29. The linker


a) Is similar to interpreter
b) Uses source code as its input
c) Is required to create a load module
d) None of the mentioned
Answer: c
Explanation: It is a program that takes one or more object files generated by a compiler
and combines them into a single executable file, library file, or another object file.

30. Shift reduce parsers are


a) Top down Parser
b) Bottom Up parser
c) May be top down or bottom up
d) None of the mentioned
Answer: b
Explanation: Also known as shift reduce parser.

31. Cross compiler is used in Bootstrapping.


a) True
b) False
Answer: a
Explanation: Bootstrapping to a new platform. When a software is developed for a new
platform, a cross compiler is used to compile necessary tools such as the OS and a native
compiler.

32. Is GCC a cross Complier


a) Yes
b) No
Answer: a
Explanation:
GCC, a free software collection of compilers, also can be used as cross compile. It
supports many languages and platforms.

33. Which concept of grammar is used in the compiler


a) Lexical analysis
b) Parser
c) Code generation
d) Code optimization
Answer: b
Explanation: As the lexical analysis of a grammar takes place in phases hence it is
synonymous to parser.

34. Which of the following are Lexemes?


a) Identifiers
b) Constants
c) Keywords
d) All of the mentioned
Answer: d
Explanation: Different Lexical Classes or Tokens or Lexemes Identifiers, Constants,
Keywords, Operators.

35. Which of the following statements is false?


a) Left as well as right most derivations can be in Unambiguous grammar
b) An LL (1) parser is a top-down parser
c) LALR is more powerful than SLR
d) Ambiguous grammar can’t be LR (k)
Answer: a
Explanation: If a grammar has more than one leftmost (or rightmost) derivation the
grammar is ambiguous. Sometimes in unambiguous grammar the rightmost derivation
and leftmost derivations may differ.

36. 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
Answer: a
Explanation: In top down parser takes input from Left to right constructing leftmost
derivation of the sentence.

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

38. The grammar A → AA | (A) | e is not suitable for predictive-parsing because the
grammar is
a) Ambiguous
b) Left recursive
c) Right recursive
d) An operator grammar
Answer: b
Explanation:
A ::= A a| b is the left recursive language.

39. In a bottom-up evaluation of a syntax directed definition its inherited attributes can do
which of the following?
a) Always evaluated
b) Can be evaluated if the definition is L attributed
c) Can be evaluated if the definition has synthesized attributes
d) Never be evaluated
Answer: b
Explanation: A Syntax Directed Definition (SDD) is called S Attributed if it has only
synthesized attributes. Also the
L-Attributed Definitions contain both synthesized and inherited attributes but do not need
to build a dependency graph to evaluate them.

40. S → C C
C→cC|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)
Answer: a
Explanation: Since there is no conflict, the grammar is LL (1) hence a predictive parse
table with no conflicts can be constructed.

41. 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
Answer: a
Explanation: Left to right constructing leftmost derivation of the sentence.

42. YACC builds up


a) SLR parsing table
b) Canonical LR parsing table
c) LALR parsing table
d) None of the mentioned
Answer: c
Explanation: It is a parser generator.

43. 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
Answer: c
Explanation: The prefixes on the stack of a shift-reduce parser are called viable prefixes.
44. A top down parser generates
a) Rightmost Derivation
b) Right most derivation in reverse
c) Left most derivation
d) Left most derivation in reverse
Answer: c
Explanation: Top-down parsing is a parsing strategy where one first looks at the highest
level of the parse tree and works down the parse tree by using the rewriting rules of a
formal grammar.

45. 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
Answer: a
Explanation: it detects local sub expression .

46. Inherited attribute is a natural choice in


a) Tracking declaration of a variable
b) Correct use of L and R values
c) All of the mentioned
d) None of the mentioned
Answer: a
Explanation: These attribute keep a check on variable declaration

47. An intermediate code form is


a) Postfix notation
b) Syntax Trees
c) Three Address code
d) All of these
Answer: d
Explanation: Intermediate code generator receives input from its predecessor phase,
semantic analyzer, in the form of an annotated syntax tree.

48. Which of the following is used for grouping of characters into tokens?
a) Parser
b) Code optimization
c) Code generator
d) Lexical analyser
Answer: d
Explanation: lexical analysis is the process of converting a sequence of characters into a
sequence of tokens.
49. A garbage is
a) Unallocated storage
b) Allocated storage whose access paths are destroyed?
c) Allocated storage
d) Uninitialized storage
Answer: b
Explanation: these are more like memory loacations with values whose pointers have
been revoked

50. Input to code generator


a) Source code
b) Intermediate code
c) Target code
d) All of the mentioned
Answer: b
Explanation: Intermediate code is the input to the code generator

51. 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
Answer: c
Explanation: Synthesized attribute’s value depend on children node only

52. _________ 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
Answer: a
Explanation: Lexical analysis is the process of converting a sequence of characters into a
sequence of tokens

53. _____________ is a graph representation of a derivation


a) The parse tree
b) Oct tree
c) Binary tree
d) None of the mentioned
Answer: a
Explanation: parse tree is a representation of the derivation
54. Which of the following is a phase of a compilation process?
a) Lexical Analysis
b) Code Generation
c) Lexical Analysis & Code Generation
d) None of the mentioned
Answer: c
Explanation: Lexical analysis and code generation is a phase of compilation process

55. A loader is a program that


a) Program that places functions into memory and prepares them for execution
b) Program that automates the translation of assembly language into machine language
c) Program accepting another program written in a high level language and produces as
object program
d) None of the mentioned
Answer: a
Explanation: A loader is the part of an operating system that is responsible for loading
programs and libraries. It is important in the process of placing the programs into
memory and executing them.

56. A system program that setup an executable program in main memory ready for execution
is
a) Assembler
b) Linker
c) Loader
d) Load and go
Answer: c
Explanation: a loader is the part of an operating system that is responsible for loading
programs and libraries. It is one of the essential stages in the process of starting a
program, as it places programs into memory and prepares them for execution

57. Assembler is a program that


a) Puts programs into memory and executes them
b) Translates the assembly language into machine language
c) Writes in high level language and produces an object program
d) None of the mentioned
Answer: b
Explanation: An assembler is a program that takes basic computer instructions and
converts them into a pattern of bits that the computer’s processor can use to perform its
basic operations.

58. Which phase of compiler is Syntax Analysis


a) First
b) Second
c) Third
d) None of the mentioned
Answer: b
Explanation: It is Second Phase Of Compiler after Lexical Analyzer.

59. What is Syntax Analyser also known as


a) Hierarchical Analysis
b) Hierarchical Parsing
c) None of the mentioned
d) Hierarchical Analysis & Parsing
Answer: d
Explanation: It is also called as Hierarchical Analysis or Parsing.

60. A compiler can check?


a) Logical Error
b) Syntax Error
c) Both Logical and Syntax Error
d) Not Logical and Syntax Error
View Answer
Answer: b
Explanation: No compiler can ever check logical errors.

61. Which of the following system software resides in the main memory always
a) Text Editor
b) Assembler
c) Linker
d) Loader
Answer: d
Explanation: Loader is used to loading programs.

62. Output file of Lex is _____ the input file is Myfile?


a) Myfile.e
b) Myfile.yy.c
c) Myfile.lex
d) Myfile.obj
Answer: b
Explanation: This Produce the filr “myfile.yy.c” which we can then compile with g++.

63. Type checking is normally done during?


a) Lexical Analysis
b) Syntax Analysis
c) Syntax Directed Translation
d) Code generation
Answer: c
Explanation: It is the function of Syntax directed translation.
64. In Short Syntax Analysis Generates Parse Tree
a) True
b) False
Answer: a
Explanation: Short Syntax Analysis generates a parse tree.

65. By whom is the symbol table created?


a) Compiler
b) Interpreter
c) Assembler
d) None of the mentioned
Answer: a
Explanation: Symbol table is created by the compiler which contains the list of lexemes
or tokens.

66. Semantic Analyser is used for?


a) Generating Object code
b) Maintaining symbol table
c) Generating Object code & Maintaining symbol table
d) None of the mentioned
View Answer
Answer: c
Explanation: Maintaining the Symbol Table for each block.
Source Program for Semantic Errors.
Collects Type Information for Code Generation.
Reporting compile-time errors in the code Generating the object code (e.g., assembler or
intermediate code).

67. 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
Answer: c
Explanation: 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.

68. The graph that shows basic blocks and their successor relationship is called
a) DAG
b)Flow graph
c) control graph
d)Hamiltonion graph
Ans : B

69. The specific task storage manager performs


A.allocation/ deallocation of storage to programs
B. protection of storage area allocated to a program from illegal access by othere programs in
the system
C.the status of each program
D.both ( a ) and ( b )
Ans :D

70. When a computer is first turned on or resrarted, a special type of absolute loader is
executed called
A." Compile and GO " loader
B. Boot loader
C.Boot strap loader
D.Relating loader
Ans : C

71. A non relocatable program is the one which


A.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
B. consists of a program and relevant information for its relocation
C.can itself perform the relocation of its address sensitive portions
D.all of these
Ans : A

72. A relocatable program form is one which


A.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
B. consists of a program and relevant information for its relocation
C.can be processed to relocate it to a desired area of memory
D.all of these
Ans : C

73. A self-relocating program is one which


A.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
B. consists of a program and relevant information for its relocation
C.can itself perform the relocation of its address sensitive portions
D.all of these
Ans : C

72. A self-relocating program is one which


A.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
B. consists of a program and relevant information for its relocation
C.can itself perform the relocation of its address sensitive portions
D.all of these
Ans : B

73 An intermediate code form is


A.postfix notation
B. syntax trees
C.three address codes
D.all of these
Ans : D

74. Three address code invloves


A.exactly 3 address
B. at the most 3 address
C.no unary operators
D.none of these
Ans : B

75. To recover from an error, the operator precedence parser may


A.insert symbols onto the stack and onto the input
B. delete symbols from the stack
C.delete symbols from the input
D.all of these
Ans : D

76. compiler work, source code into______?.


Machine code
B. Executable code
C. Binary code
D. Both B and C
E. Both A and C
Ans : E

77. one or more parse tree for some sentence, that is ________grammer.
Unambiguous
b) Ambiguous
c) Both A and B
d) None of these
Ans :B

78. A lexical analyzer produce__________?


A.Machine code
B. Binary code
C. tokens
D. Both A and B
E. None of these
Ans : C

79. The parts of the compiler are ____.


A.6
B. 8
C. 2
D. 3
E. None of these
Ans ; C

80. compiler indicate the ______error.


A. Syntax error
B. Logical error
C. Run time error
D. All of these
Ans : A

90. _______ is not a phase of compiler.


A.syntax
B. testing
C. lexiacal
D. Both A and C
E. None of these
Ans : B

91. Parsing is also called______ analysis?


A.semantic
B. lexical
C. syntax
D. Both A and B
Ans : C

92. A process, a string of tokens can be generated by_______.


A.Parsing
B. Analysing
C. Translating
D. All of these
Ans : A

---------------------------------------***ALL THE BEST***--------------------------------------------

You might also like