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

one mark

Faq

Uploaded by

praveenarmy91202
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)
33 views

one mark

Faq

Uploaded by

praveenarmy91202
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/ 18

MCQ- PRINCIPLES OF COMPILER DESIGN -BMF for MCA &M.Sc.

,cs

SUBJECT TITILE : COMPILER DESIGN


SUBJECT CODE : 17PCS3C10
CLASS : II M.Sc CS
SEMESTER : III

UNIT-I

1. Which of the following is not a phase of compiler?

a. syntax b. lexical 👍🏻 c. testing d. code generation

2. In compiler, Source program is read by

a. parser b. lexical analyzer 👍🏻c. developer d. analyst

3. Source program is read

a. character by character 👍🏻b. line by line c. page by page d. module wise

4. Output of lexical analysis phase is

👍🏻a. token b.parse tree c.code d.object code

5. Compiler

a. reads source program b. converts it into target language

👍🏻 c. both a and b d. none of the above

6. a* means

👍🏻a. {eppsilon,a,aa,...} b. {a,aa,..}

c. {a,aa,aaa,aaa} d. {a,aa,aaa,aaa,...}

7. a+ means

a. {eppsilon,a,aa,...} 👍🏻b. {a,aa,..}

c. {a,aa,aaa,aaa} d. {a}

8. token for If is

a. Id b. keyword 👍🏻c. If d. string


9. Token for "compiler" is

a. keyword b. string c. Id 👍🏻d. literal

10. A compiler is

a. A program that place program into memory and prepares them for execution
b. A program that automates the translation of assembly language into machine
language
👍🏻 c. program that accepts program written in high level language and produces an
object program
d. A program that appears to execute a source program as if it were machine
language

11. Output of parser is

a. set of tokens 👍🏻b. parse tree c. object code d. intermediate code

12. Grammar is ambiguous if

a. it has 2 parse trees b. it has two left most derivations

c. it has two right most derivations 👍🏻d. all of the above

13. The concept of grammar is much used in this part of the compiler

a. lexical analysis 👍🏻b. parser

c. code generation d. code optimization

14.The concept of FSA is much used in this part of the compiler

👍🏻a. lexical analysis b. parser

c. code generation d. code optimization

15.Parsing is also known as

👍🏻a. syntax anlysis b. lexical analysis


c. semantic analysis d. code generation
16. Input buffer is

a. symbol table 👍🏻b. divided into two halves

c. divided into Three halves d. not divided


17.Select a Machine Independent phase of the compiler
a) Syntax Analysis 👍🏻b) Intermediate Code generation
c) Lexical Analysis d) All of the mentioned

18. A system program that combines the separately compiled modules of a program
into a form suitable for execution?
a) Assembler b) Compiler
👍🏻c) Linking Loader d) Interpreter

19. Which of the following system software resides in the main memory always
a) Text Editor b) Assembler
c) Linker 👍🏻d) Loader
20. System program such as Compiler are designed so that they are __________
A. Recursive B. Non-reusable
C. Serially usable 👍🏻D. Re-enterable

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

22.Users write the programs in which language?

0. a)Low-level Language
a. 0b)High-Level Language
b. c)Decimal-Format
c. d)Middle-Level Language

23.Does the compiler program translate the whole source code in one step?

0. a)No
a. b)Depends on the Compiler
b. c)Don't Know
c. 0d)Yes

24. Token for "compiler" is

a) keyword

b) string

c)Id

0d) literal

25.Which of the following file is an output of the assembler?


0. a)Program file
a. 0b)Object file
b. c)Data File
c. d)Task File

26. Which of the following is not a phase of compiler?

a) syntax

b) lexical

0c) testing

d) code generation

27. In compiler, Source program is read by

a) parser

0b) lexical analyzer

c) developer

d) Analyst

28. Source program is read

a)character by character

0b)line by line

c)page by page

d) module wise

29. Output of lexical analysis phase is

0a)token

b)parse tree

c)code

d) object code

30. Compiler

a) reads source program


b) converts it into target language

0c) both a and b

d) none of the above

UNIT II
1. A grammer gives ……… specification of a programming language.
a) Semantic b) concise 0c) syntactic d) consistent
2. The basic symbols of strings in a language are composed of
a) Symbol tables 0b) terminals c) symbols d) symbolic language
3. Lowercase letters are categorized as
a) Terminals 0 b) non terminals c) start symbols d) production
4. A graphical representation for derivations called a
a) Ans. Parse tree b) grammar c) ambiquity d) flowchart
5. A grammar that produces more than one parse tree for a sentence is said to be
a) Unambiguous 0b) ambiguous c) confused grammar d) illegal grammar
6. Exponentiation operator is ………….. associative
a) Left 0b) right c) neither right nor left d) both
7. A parser accepts string w as input and produces output as
a) Syntax tree b) binary tree 0c) parse tree d) primary tree
8. A rightmost derivation in reverse called a
a) Parse tree 0 b) canonical reduction c) error d) right sentential form
9. A grammar for which we can construct a parsing table in which every entry is
uniquely defined is called
a) SLR parser 0b) predictive parser c) LR parser d) LALR parser
10.Which one is a non terminal?
a) if b) id c) digits 0d) start symbol
11. a<.b implies
a) a is less than b b) a has smaller value than b 0c) a yields precedence to b
d) a takes precedence over b
12. In an error action of shift reduce parsing, the parser calls
0a) an error recover routine b) a function c) a method d) a recursive
function
13. All keywords are
a) non terminals 0b) terminals c) start symbol d) both terminal and non
terminal
14. Backtracking problem is usually occurred in
a) shift reduce parsing b) operator precedence parsing 0c) top down parsing
d) handle pruning
15. When the statements s…>cAd and a…..>ab, then S can be replaced as:
0a) s….>cabd b) s…..>cad c) s……….> cababd d) s………..> cab
16. ……… parser is an efficient way of implementing recursive descent parsing
a) shift reduce b) topdown c) operator precedence 0d) predictive
17. FIRST and FOLLOW are the functions used in ………… algorithm
0a) predictive b) shift c) topdown d) all
18. A method used to manipulate on grammars to make it suitable for recursive
descent
Parsing is
a) Handle pruning 0b) left factoring c) canonical reduction d) right
factoring
19. The reserved word if is considered to be as
a) nonterminal 0b) terminal c) start symbol d) keyword
20. The parsing technique used to reduce the right sentential form is
a) recursive descent parsing 0 b) shift reduce parsing c) top down parsing
d) bottom up parsing.

21. A grammer gives ……… specification of a programming language.


b) Semantic
c) 0b) concise
d) c) syntactic
e) d) consistent
22 The basic symbols of strings in a language are composed of
b) Symbol tables
c) b) terminals
d) c) symbols
e) 0d) symbolic language
23. The grammar S → aSa | bS | c is?
a) LL(1) but not LR(1)
b) LR(1) but not LR(1)
0c) Both LL(1) but not LR(1) & LR(1) but not LR(1)
d) None of the mentioned

24. Recursive descent parsing is an example of ____________


0a) Top down parsing
b) Bottom up parsing
c) Predictive parsing
d) None of the mentioned

25. LR stands for ___________


a) Left to right
b) Left to right reduction
c) Right to left
0d) Right most derivation and Left to right and a in reverse

26.A bottom-up parser generates ___________


a) right-most derivation
b) left-most derivation
0c)right-most derivation in reverse
d) left-most derivation in reverse
27.A top-down parser generates ___________
a) right-most derivation
0b) left-most derivation
c) right-most derivation in reverse
d) left-most derivation in reverse
28.A form of recursive-descent parsing that does not require any back-tracking is
known
as__________
0a) Predictive parsing
b) Recursive-descent parsing
c) Both (A) and (B)
d) None of the above

29.__________ checks whether the parse tree constructed follows the rules of a
language.
a)Syntax Analysis
0b) Semantic Analysis
c)Lexical Analysis
d) None of the above
30.Which of the following is/are advantage(s) of Compiler Technology?
a) Parsers for HTML in web browser
b) Software testing
c) Malicious code detection
0d) All of the above
UNIT-III
1. intermediate code form is
a) Postfix Notation b) Syntax Trees
c) Three address 0d) All of the mentioned

2. The best way to compare the different implementations of symbol table is to


compare the time required to
a) Add a new name b) Make an enquiry
c) Add a new name and make an enquiry 0d) All of the mentioned

3. Dynamic linking can cause security concerns because


a) Security is dynamic b) None of the mentioned
c) Both of the mentioned 0d) Cryptographic procedures are not available for
dynamic linking

4. Which of the following statements is FALSE?


a) Both of the mentioned b) In up-typed languages, values do not have any
types
0c) Dynamic languages have no variables types d) None of the mentioned

5.What data structure in a complier is used for managing information about variables
and their attributes?
a) Abstract syntax tree 0 b) Symbol table
c) Semantic stack d) Parse table
6.Compiler translates the source code to
A. Executable code B. Machine code
C. Binary code 0D. Both B and C

7. Which of the following groups is/are token


together into semantic structures?
A. Syntax analyze
B. Intermediatecodegeneration
0C. Lexical analyzer D. Semanticanalyzer

8. Compiler should report the presence of


__________ in the source program, in
translation process.
A. Classes B. Objects
0C. Errors D. Text

9. What is the output of lexical analyzer?


A. A parse tree 0B. A list of tokens
C. Intermediate code D. Machine code

10.In a single pass assembler, most of the forward references can be avoided by
putting the restriction
A.on the number of strings/life reacts
0 that the data segment must be defined after the code segment.
b
B.
C.on unconditional rump.
D.None of these

11.The method which merges the bodies of two loops is


A.loop rolling
0 loop Jamming
b
B.
C.constant folding
D.none of these

12. Assembly code data base is associated with


0 assembly language version of the program which is created by the code.
A.

B.a permanent table of decision rules in the form of patterns for matching with the
uniform symbol table to discover syntactic structure.
C.Both (a) and (b)
D.a permanent table which lists all key words and special symbols of the language
in symbolic form.

13. The process manager has to keep track of


A status of each program
.
0 priority of each program
B.
C.information management support to a programmer using the system.
D Both (A) and (C)
.

14.Function of the syntax phase is to


0 recognize the major constructs of the language and to cal the appropriate action
A.routines that wil generate the intermediate form or matrix for these constructs
B.build a literal table and an identifier table.
C.build a uniform symbol table.
D.parse the source program into the basic elements or tokens of the language.

15. The action of parsing the source program into proper syntactic classes is called
a) Syntax analysis 0b) Lexical analysis
c) Interpretation analysis d) General syntax analysis
16. Which languages necessarily need heap allocation in the runtime environment?
a) Those that support recursion
b) Those that use dynamic scoping
0c) Allow dynamic data structure
d) Those that use global variables

17. Type checking is normally done during


a) Lexical analysis b) Syntax analysis
0c) Syntax directed translation d) Code generation

18. Cache memory acts between_______


0a) CPU and RAM b) RAM and ROM
c) CPU and Hard Disk d) None of the mentioned

19. . The postfix form of the expression (A+ B)*(C*D- E)*F / G is?

0a) AB+ CD*E - FG /** b) AB + CD* E - F **G /


c) AB + CD* E - *F *G / d) AB + CDE * - * F *G /

20. The postfix form of A*B+C/D is?

a) *AB/CD+ 0 b) AB*CD/+
c) A*BC+/D d) ABCD+/*

21. Which of the following structure has four fields?


0. Parse tree
a. Triples
b. Ans.Indirect Triples
c. Quadruples

22. In which of the following tree, the leaf indicates the operand, and the interior node
represents the operator.

0. Ans.Syntax tree
a. Parser tree
b. Structured tree
c. Sematic tree

23. Which statement is an abstract form of intermediate code?

0. Ans.3- address
a. 2-address
b. address
c. Intermediate code

24. Which mapping is described by the implementation of the syntax-directed


translator?

0. Parse table
a. Ans.Input
b. Output
c. Input-Output

25. Which of the following function is called the canonical collection of LR(0) item.

0. Ans.FIRST
a. GOTO
b. COMPUTE
c. FOLLOW

26. Which of the following option is not a function of the shift-reduce parser?

0. Reduce
a. Accept
b. Ans.Go
c. Shift

27. Which of the following grammar has no two adjacent non-terminals?


0. Irregular grammar
a. Regular grammar
b. Ans.Operator
c. Precedence grammar

28. intermediate code form is


a) Postfix Notation
b) Syntax Trees
c) Three address
0d) All of the mentioned
29. The best way to compare the different implementations of symbol table is to
compare the time required to
a) Add a new name
b) Make an enquiry
c) Add a new name and make an enquiry
0d) All of the mentioned

30. Dynamic linking can cause security concerns because


a) Security is dynamic
b) None of the mentioned
c) Both of the mentioned
0d) Cryptographic procedures are not available for dynamic linking
UNIT IV
1.Which of the following symbol table implementation has the minimum access time?
a.Self-organizing list
b.Linear
c.Search tree
0d.Hash table

2. The third phase of a compiler is


a) code generation b) syntax analysis c) lexical analysis 0d) intermediate code
generation
3. The simplest and easiest way to implement the data structure for a symbol table is
a) search trees b) self-organizing lists 0 c) lists d) hash tables
4. In a hashing scheme, hash table and ……….. table are used
0a) storage b) link c) data d) symbol
5. Stack pointer always points to a particular position in the ……. record for
currently
active procedure
a) Previous 0b) activation c) deleted d) new
6. One of the primary issues in the symbol table is
0a) format of the entries b) data type c) value of the data d) validity of the data
7. A record consists of a known number of consecutive ………. of memory
a) data b) bytes 0c) words d) bits
8. A compiler is designed to run in less space if the space is ……….. in subsequent
passes
a) Deleted b) exchanged c) shared 0d) reused
9.The main dis advantage in lists is
a) poor performance 0b) slow c) not popular d) fastness
10. The major drawback of self organizing list is
a) not efficient b) not reliable 0c) time & space d) not flexible
11. One way to store an pointer with each procedure called
a) dynamic link 0b) static link c) pointer link d) top of the stack
12. A simple compiler
a) cannot detect error b) may or may not detect error c) hangs the system
0d) stops all activities when an error is occurred
13. A complex compiler
0a) repairs the error b) reports the error c) scans the error d) ignores the error
14. A sophisticated compiler
a) deletes the error b) stops the error 0 c) attempts to correct the erroneous input
d) attempts to hangs the system
15. In the following PL/1 programming statements, which one has syntax error?
a) if a=b then b) do 10, i=1,100 c) do while(0<i<10) 0d) min(a,2*(3+b)
16. When the algorithm is inadequate to meet the design, it is called
0a) algorithmic error b) algorithmic fault c) inadequate algorithm d)
inadequate
design
17. Undeclared or multiply declared variables come under
a) syntax error 0b) semantic error c) runtime error d) dynamic error
18. Araay range out of bounds is
a) not an error b) stack underflow 0c) dynamic error d) logical error
19. In ………. mode, a parser discards input symbols until a delimiter is encountered
a) deleimiter b) input c) output 0d) panic
20. A theoritical way of defining errors and their location is
a) hash table entry 0b) minimum hamming distance c) transition table entry d)
error table.

21. The information about data is entered into a data structure is called
a) transition table 0b) symbol table c) data table d) information table
22. The third phase of a compiler is
a) code generation b) syntax analysis c) lexical analysis 0d) intermediate code
generation
23. The simplest and easiest way to implement the data structure for a symbol table is
a) search trees b) selft organizing lists 0c) lists d) hash tables
24. In a hashing scheme, hash table and ……….. table are used
0a) storage b) link c) data d) symbol
25. Stack pointer always points to a particular position in the ……. record for
currenctly
active procedure
b) Previous 0b) activation c) deleted d) new
26. One of the primary issues in the symbol table is
0 a) format of the entries b) data type c) value of the data d) validity of the data
27. A record consists of a known number of consecutive ………. of memory
a) data b) bytes 0c) words d) bits
28. A compiler is designed to run in less space if the space is ……….. in subsequent
passes
b) Deleted b) exchanged c) shared 0d) reused
29.The main dis advantage in lists is
a) poor performance 0b) slow c) not popular d) fastness
30. The major drawback of self organizing list is
a) not efficient b) not reliable 0 c) time & space d) not flexible

UNIT V
1. An alternate term for code optimization is
a) code compilation b) code translation c) code developing 0d) code
improvement
2. Code optimization techniques are applied
0a) after syntax analysis b) before syntax analysis c) before aligning d) after
compilation
3. It is used to portray the basic blocks and their successor relationships by a directed
graph
a) Simulated graph 0b) flow graph c) flowchart d) transition diagram
4. When the value of a variable is changing at each step in a loop called
a) undefined variable b) undeclared variable c) uninitialized variable 0d)
induction
variable
5. The replacement of an expensive operation by a cheaper one is termed as
a) cheaper operation b) inexpensive operation 0c) reduction in strength d)
replaced
operation
6. In ……… we take a computation that yields the same result independent of the
number of times in a loop
a) Ans. code motion b) code invariant c) loop invariant d) invalid code
7. A statement that quits the loop based on some condition satisfied called
a) unconditional jump 0b) conditional jump c) conditional skip d)
unconditional
skip
8. One of the problem in code generation phase is
0a) what registers to use b) how to write a code c) how to compile d) how to
clear
errors
9.The major advantage of using registers is
a)| easy to implement b) it simplifies the design of a compiler c) inexpensive
0 d) easy to use
10. The major drawback of using registers is
a) lack of memory space 0b) inefficient use of registers c) costly d) not
sufficient
11. Unconditional jump may results in
0a) unreachable code b) unnecessary skips c) unwanted code d) unreliable
code
12. A technique that deals with optimizing the intermediate or object code is
a) loophole optimization b) object code generation 0c) peephole optimization
d) code reduction
13. Multiple jumps results in
a) optimized code b) time delay 0c) efficient code d) faster code
14. Redundant loads and stores results in
a) efficient run 0b) wasted time and space c) good algorithm d) efficient
programming
15. An approach to keep frequently used name in a fixed register throughout the loop
Called
a) Ans. Global register allocation b) inner loop c) local variable d) inner
variable
16. Conditional statements are used in
a) program b) global registers 0c) loops d) global variables
17. ………… that keeps track of the local of current value of a variable at runtime
a) address block b) stack c) pointer 0d) address descriptor
18. Good code generation depends on
a) programmer 0b) hardware factors c) user manual d) software engineer
19. In IBM System/370 machines, which one is the multiplication instruction?
0a) M X, Y b) MUL X, Y c) MUL Y, X d) PROD X, Y
20. The instruction MOV R0, R1 implies
0a) copies R1 into R0 b) moves R1 into R0 c) copies R0 into R1 d) moves
R0
into R1

21. An alternate term for code optimization is


a) code compilation b) code translation c) code developing 0d) code
improvement
22. Code optimization techniques are applied
0a) after syntax analysis b) before syntax analysis c) before aligning d) after
compilation
23. It is used to portray the basic blocks and their successor relationships by a
directed
graph
b) Ans. Simulated graph b) flow graph c) flowchart d) transition diagram
24. When the value of a variable is changing at each step in a loop called
a) undefined variable b) undeclared variable c) uninitialized variable 0d)
induction
variable
25. The replacement of an expensive operation by a cheaper one is termed as
a) cheaper operation b) inexpensive operation 0c) reduction in strength d)
replaced
operation
26. In ……… we take a computation that yields the same result independent of the
number of times in a loop
b) Ans. code motion b) code invariant c) loop invariant d) invalid code
27. A statement that quits the loop based on some condition satisfied called
a) unconditional jump 0b) conditional jump c) conditional skip d)
unconditional
skip
28. One of the problem in code generation phase is
0a) what registers to use b) how to write a code c) how to compile d) how to
clear
errors
29.The major advantage of using registers is
a)| easy to implement b) it simplifies the design of a compiler c) inexpensive
0d) easy to use
30. The major drawback of using registers is
a) lack of memory space 0b) inefficient use of registers c) costly d) not
sufficient

…………………………………………………………………………………………

ANSWER KEY

UNIT I

1. c. testing
2. c. lexical analyser
3. b. line by line
4. a. token
5. c. both a and b
6. a. {epsilon, a, aa,….}
7. b. {a,aa,…}
8. c. if
9. d. literal
10. c. program that accepts program written in high level language and
produces an object program
11. b. parse tree
12. d. all the above
13. b. parser
14. a. lexical analysis
15. a. syntax analysis
16. b. divided into two halves
17. b. intermediate code generation
18. c. linking loader
19. d. loader
20. d. re-enterable
21.c) is required to create a load module
22.b)high-level language
23.d)yes
24. d) literal
25.b)object file
26. c) testing
27. b) lexical analyzer
28.b)line by line
29.a)token
30. c) both a and b

UNIT II
1. c) syntactic
2. b) terminals
3. b) non terminals
4. a) parse tree
5. b) ambiguous
6. b) right
7. c) parse tree
8. b) canonical reduction
9. b) predictive parser
10. d) start symbol
11. c) a yields precedence to b
12. a) an error recover routine
13. b) terminals
14. c) top-down
15. a) s-🡪cabd
16. d) predictive
17. a) predictive
18. b) left factoring
19. b) terminal
20. b) shift reduce parsing
21. b) concise
22 .d) symbolic language
23. c) Both LL(1) but not LR(1) & LR(1) but not LR(1)

24. a) Top down parsing


25. d) Right most derivation and Left to right and a in reverse
26.c)right-most derivation in reverse
27.b) left-most derivation
28.a) Predictive parsing
29. b) Semantic Analysis
30.d) All of the above

UNIT III

1. d. all the above


2. d. all the above
3. d. cryptographic procedures are not available for dynamic linking
4. c. dynamic languages have no variable types
5. b. symbol table
6. d. both a and c
7. c. lexical analyzer
8. c. errors
9. b. a list of tokens
10. b. that the data segment must be defined after the code segment
11. b. loop jamming
12. a. assembly language version of the program which is created by the code
13. b. both a and c
14. a. recognize the major constructs of the language and to cal the appropriate action
routines that wil generate the intermediate form or matrix for these constructs
15. b. lexical analysis
16. c. allow dynamic data structure
17. c. syntax directed translation
18. a. CPU & RAM
19. a. AB+ CD*E - FG /**
20. b. AB*CD/+

21.b.Quadruples
22.a.Syntax tree
23.a.3- address
24.b.Input-Output
25.a.GOTO
26.c.Go
27.c.Operator
28.d) All of the mentioned
29. d) All of the mentioned
30. d) Cryptographic procedures are not available for dynamic linking

UNIT IV
1. d)hash table
2. d) intermediate code generation
3. c) lists
4. a) storage
5. b) activation
6. a) format of the entries
7. c) words
8. d) reused
9. b) slow
10. c) time and space
11. b) static link
12. d) stops all activities when an error is occurred
13. a) repairs the error
14. c) attempts to correct the erroreous input
15. d) min(a, 2*(3+b)
16. a) algorithmic error
17. b) semantic error
18. c) dynamic error
19. d) panic
20. b) minimum hamming distance
21. b) symbol table
22. d) intermediate code generation
23. c) lists
24. a) storage
25. b) activation
26. a) format of the entries
27. c) words
28. d) reused
29. b) slow
30. c) time and space

UNIT V
1. d) code improvement
2. a) after syntax analysis
3. b) flow graph
4. d) induction variable
5. c) reduction in strength
6. a) code motion
7. b) conditional jump
8. a) what registers to use
9. d) easy to use
10. b) inefficient use of memory
11. a) unreachable code
12. c) peephole optimization
13. c) time delay
14. b) wasted time and space
15. a) global register allocation
16. c) loops
17. d) address descriptor
18. b) hardware factors
19. a) M X, Y
20. a) copies R1 into R0
21. d) code improvement
22. a) after syntax analysis
23. b) flow graph
24. d) induction variable
25. c) reduction in strength
26. a) code motion
27. b) conditional jump
28. a) what registers to use
29. d) easy to use
30. b) inefficient use of memory

-------------------------------------------------------------------------------------------------------

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy