0% found this document useful (0 votes)
305 views10 pages

Compiler Mcqs

This document contains questions and answers related to compilers and programming language concepts. It covers topics like lexical analysis, parsing, grammars, finite automata, ambiguity, and linear grammars. The questions are multiple choice with explanations for the answers provided.

Uploaded by

Hamid Bashir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
305 views10 pages

Compiler Mcqs

This document contains questions and answers related to compilers and programming language concepts. It covers topics like lexical analysis, parsing, grammars, finite automata, ambiguity, and linear grammars. The questions are multiple choice with explanations for the answers provided.

Uploaded by

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

1. Which of the following is the fastest logic ?

a)TTL
b)ECL
c)CMOS
d)LSI
View Answer
Answer:b
Explanation: In electronics, emitter-coupled logic (ECL) is a high-speed integrated circuit.
2.A bottom up parser generates
a)Right most derivation
b)Rightmost derivation in reverse
c)Leftmost derivation
d)Leftmost derivation in reverse
View Answer
Answer:b
Explanation: This corresponds to starting at the leaves of the parse tree also known as shift-reduce parsing.
3. A grammar that produces more than one parse tree for some sentence is called
a)Ambiguous
b)Unambiguous
c)Regular
d)None of the mentioned
View Answer
Answer:a
Explanation: ambiguous grammar has more than one parse tree.
4.An optimizer Compiler
a)Is optimized to occupy less space
b)Both of the mentioned
c)Optimize the code
d)None of the mentioned
View Answer
Answer:d
Explanation: In computing, an optimizing compiler is a compiler that tries to minimize or maximize some attributes of
an executable computer program
5.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
View Answer
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.
6.A latch is constructed using two cross coupled
a)AND OR gates
b)AND gates
c)NAND and NOR gates
d)NAND gates
View Answer
Answer: d
7.Pee Hole optimization
a)Loop Optimization
b)Local Optimization
c)Constant folding
d)Data Flow analysis
View Answer
Answer: c
8.The optimization which avoids test at every iteration is
a)Loop unrolling
b)Loop jamming
c)Constant folding
d)None of the mentioned
View Answer
Answer: a
9Scissoring enables
a)A part of data to be displayed
b)Entire data to be displayed
c)None of the mentioned
d)No data to be displayed
View Answer
Answer: a
10.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
View Answer
Answer:b
11.The output of lexical analyzer is
a)A set of RE
b)Syntax Tree
c)Set of Tokens
d)String Character
View Answer
Answer: c
12. . The symbol table implementation is based on the property of locality of reference is
a) Linear list
b) Search tree
c) Hash Table
d) Self Organisation
View Answer
Answer: c
13.For operator precedence parsing, which one is true?
a)For all pair of non-terminal
b)For all pair of non-terminals
c)To delimit the handle
d)None of the mentioned
View Answer
Answer:a

14. Object program is a


a) Program written in machine language
b) Program to be translated into machine language
c) Translation of high-level language into machine language
d) None of the mentioned
View Answer
Answer: c
15. Which concept of FSA is used in the compiler?
a) Lexical analysis
b) Parser
c) Code generation
d) Code optimization
View Answer
Answer: a
16. Which concept of grammar is used in the compiler
a) Lexical analysis
b) Parser
c) Code generation
d) Code optimization
View Answer
Answer: b
17.  Which of the following are Lexemes?
a) Identifiers
b) Constants
c) Keywords
d) All of the mentioned
View Answer
Answer: d
18. What constitutes the stages of the compilation process?
a) Feasibility study, system, design, and testing
b) Implementation and. documentation
c) Lexical analysis, syntax. Analysis and code generation
d) None of the mentioned
View Answer
Answer: c
19. The lexical analyzer takes_________as input and produces a stream of_______as output.
a) Source program, tokens
b) Token, source program
c) Either of the two
d) None of the mentioned
View Answer
Answer: a
20. Parsing is also known as
a) Lexical Analysis
b) Syntax Analysis
c) Semantic Analysis
d) Code Generation
View Answer
Answer: b
21. A compiler program written in a high level language is called
a) Source Program
b) Object Program
c) Machine Language Program
d) None of the mentioned
View Answer
Answer: a
22. System program such a compiler are designed so that they are
a) Re-enterable
b) Non-Usable
c) Serially usable
d) None of the mentioned
View Answer
Answer: a
23. Which of the following is not feature of compiler?
a) Scan the entire program first and translate into machine code
b) To remove syntax errors
c) Slow for debugging
d) Execution time is more
View Answer
Answer: d
24.  A system program that brings together separately compiled modules of a program into a form language that is
suitable for execution
a) Assembler
b) Linking loader
c) Cross compiler
d) None of the mentioned
View Answer
Answer: b
25. In a compiler the module that checks every character of the source text is called
a) The code generator
b) The code optimizer
c) The lexical analyzer
d) The syntax analyzer
View Answer
Answer: a
26. The context free grammar is ambiguous if
a) The grammar contains non-terminals
b) Produces more than one parse tree
c) Production has two non-terminals side by side
d) None of the mentioned
View Answer
Answer: b
27. Another Name for Lexical Analyser
a) Linear Phase
b) Linear Analysis
c) Scanning
d) All of the mentioned
View Answer
Answer: d
28. An individual token is called ________
a) Lexeme
b) Lex
c) Lexeme & Lex
d) None of the mentioned
View Answer
Answer: a
29.  Lexical Analyser’s Output is given to Syntax Analysis.
a) True
b) False
View Answer
Answer: a
30. Which phase of the compiler is Lexical Analyser?
a) First
b) Second
c) Third
d) None of the mentioned
View Answer
Answer: a
31. Input to Lexical Analyser is
a) Source Code
b) Object Code
c) Lexeme
d) None of the mentioned
View Answer
Answer: a
32.  Lexical Analysis Identifies Different Lexical Units in a _______
a) Source Code
b) Object Code
c) Lexeme
d) None of the mentioned
View Answer
Answer: a
33. Which one is a type of Lexeme
a) Identifiers
b) Constants
c) Keywords
d) All of the mentioned
View Answer
Answer: d
34. A________ is a string of characters which form a syntactic unit.
a) Lexeme
b) Lex
c) Lexeme & Lex
d) None of the mentioned
View Answer
Answer: a
35. The process of forming tokens from an input stream of characters is called_____
a) Liberalisation
b) Characterisation
c) Tokenization
d) None of the mentioned
View Answer
Answer: c
36. When expression sum=3+2 is tokenized then what is the token category of 3
a) Identifier
b) Assignment operator
c) Integer Literal
d) Addition Operator
View Answer
Answer: c
37. Which grammar defines Lexical Syntax
a) Regular Grammar
b) Syntactic Grammar
c) Context free Grammar
d) Lexical Grammar
View Answer
Answer: d
38. Two Important lexical categories are
a) White Space
b) Comments
c) None of the mentioned
d) White Space & Comments
View Answer
Answer: d
39. It has encoded within it information on the possible sequences of characters that can be contained within any of
the tokens it handles .Above motioned function is performed by?
a) Scanner
b) Parser
c) Syntactic Analyser
d) All of the mentioned
View Answer
Answer: a
40. What goes over the characters of the lexeme to produce a value?
a) Scanner
b) Parser
c) Evaluator
d) Lexical generator
View Answer
Answer: a
41.  Lexers are often generated by a lexer generator, same as parser generators,
a) True
b) False
View Answer
Answer: a
42. Which one is a lexer Generator
a) ANTLR
b) DRASTAR
c) FLEX
d) All of the mentioned
View Answer
Answer: d
43. Which of the lexical analyser can handle Unicode
a) Java CC
b) JFLex
c) Quex
d) All of the mentioned
View Answer
Answer: d
44. The output of a lexical analyzer is
a) Machine Code
b) Intermediate Code
c) Stream of Token
d) Parse Tree
View Answer
Answer: c
45. Non-Linear grammar has has two non-terminals on the right-hand side.
a) True
b) False
View Answer
Answer: a
46.  S → SS S → λ S → aSb S → bSa which type of grammar is it?
a) Linear
b) Nonlinear
c) Both of the mentioned
d) None of the mentioned
View Answer
Answer: a
47. Linear grammar has more than one non-terminal on the right-hand side.
a) True
b) False
View Answer
Answer: a
48. In Right-Linear grammars, all productions have the form: A → xB.
a) True
b) False
View Answer
Answer: a
49. S → abS S → a is which grammar
a) Right Linear Grammar
b) Left Linear Grammar
c) Both of the mentioned
d) None of the mentioned
View Answer
Answer: a
50.  What are the two types of Linear Grammar?
a) Right Linear
b) Left Linear
c) None of the mentioned
d) Both of the mentioned
View Answer
Answer: d
51. Which Grammar is it?
a) Right Linear
b) Left Linear
c) None of the mentioned
d) Both of the mentioned
View Answer
Answer: b
52. Which Type of Grammar is it?
S → Aa A → Aab | λ
a) Right Linear
b) Left Linear
c) None of the mentioned
d) Both of the mentioned
View Answer
Answer: b
53. A Regular Grammar is any right-linear or left-linear grammar.
a) True
b) False
View Answer
Answer: a
54. Regular Grammars generate Regular Languages.
a) True
b) False
View Answer
Answer: a
55. Can Left Linear grammar be converted to Right Linear grammar
a) Yes
b) No
View Answer
Answer: a
56. CFG is
a) Compiler
b) A language expression
c) Regular Expression
d) None of the mentioned
View Answer
Answer: b
57. The idea of an automation with a stack as auxiliary storage
a) Finite automata
b) Push Down Automata
c) Deterministic Automata
d) None of the mentioned
View Answer
Answer: b
58. Transition of finite automata is
a) Finite Diagram
b) State Diagram
c) Node Diagram
d) E-R Diagram
View Answer
Answer: b
59. A context free language is called ambiguous if
a) It has 2 or more than 2 left derivations for some terminal string ѡ є L (G)
b) It has 2 or more than 2 left derivations for some terminal string ѡ є L (G)
c) Both (a) and (b)
d) None of the mentioned
View Answer
Answer: c
60. Which of the following statement is true?
a) Every language that is defined by regular expression can also be defined by finite automata
b) Every language defined by finite automata can also be defined by regular expression
c) We can convert regular expressions into finite automata
d) All of the mentioned
View Answer
Answer: d
61. Which of the following identity is wrong?
a) R + R = R
b) (R*)* = R*
c) ɛR = Rɛ = R
d) ØR = RØ = RR*
View Answer
Answer: d
62. Grammars that can be translated to DFAs
a) Left linear grammar
b) Right linear grammar
c) Generic grammar
d) All of the mentioned
View Answer
Answer: b
63.  A language is regular if and only if it is accepted by finite automata
a) The given statement statement is true
b) Given statement is false
c) Statement is partially true
d) None of the mentioned
View Answer
Answer: a
64. A Push Down Automata is if there is at most one transition applicable to each configuration
a) Deterministic
b) Non deterministic
c) Finite
d) Non finite
View Answer
Answer: a
65. Terminal table
a) Contains all constants in the program
b) Is a permanent table of decision rules in the form of patterns for matching with the uniform symbol table to discover
syntactic structure
c) Consist of a full or partial list of the token is as they appear in the program created by lexical analysis and used for
syntax analysis and interpretation
d) Is a permanent table which lists all keywords and special symbols of the language in symbolic form
View Answer
Answer: d
66. Advantage of incorporating the macro-processor into pass 1 is that
a) Many functions have to be implemented twice
b) Functions are combined not necessarily creating intermediate files as output from the macro-processor and input
to the assembler
c) More flexibility is provided to the programmer in that he may use all the features of the assembler in conjunction
with macros
d) All of the mentioned
View Answer
Answer: d
67. Which of the following is a phase of a compilation process?
a) Lexical Analysis
b) Code Generation
c) Both of the mentioned
d) None of the mentioned
View Answer
Answer: c
68. System program such a s compiler are designed so that they are
a) Re-enterable
b) Non reusable
c) Serially usable
d) None of the mentioned
View Answer
Answer: a
69. A series of statements explaining how the data is to be processed is called
a) Assembly
b) Machine
c) COBOL
d) Program
View Answer
Answer: d
70. 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
View Answer
Answer: a
71. 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
View Answer
Answer: c
72. Which of the following system program forgoes the production of object code to generate absolute machine code
and load it into the physical main storage location from which it will be executed immediately upon completion of the
assembly?
a) Two pass assembler
b) Load and go assembler
c) Macro processor
d) Linker
View Answer
Answer: b
73. Uniform symbol table
a) Has all constants in the program
b) Permanent table of rules in the form of patterns for matching with the uniform symbol table to discover syntactic
structure
c) Consists of full or partial list of the tokens as they appear in the program created by Lexical analysis and used for
syntax analysis and interpretation
d) A permanent table which has all key words and special symbols of the language in symbolic form
View Answer
Answer: c
74. 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
View Answer
Answer: b
75. 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
76. 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
77.  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
78. 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
79. 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
80. 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
81. 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
82.  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
83.  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
84. 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

You might also like