Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

Academy of Technology

Sub: Compiler Design MCQ Paper Code: MCA 504A

1. A translator that takes as input a high-level language program and


translates into machine language is known as [1]
A. Compiler
B. Interpreter
C. Pre-processor
D. Assembler

2. _______ creates a single program from several files of relocated machine


code. [1]
A. Loaders
B. Assemblers
C. Link editors
D. Pre processors

3. A group of logically related characters in the source program is known


as ________. [1]
A. Token
B. Lexeme
C. Parse Tree
D. Buffer

4. The _______ uses the parse tree and symbol table checking the semantic
consistency of the source program. [1]
A. Lexical analyser
B Intermediate Code Generator
C. Syntax translator
D. Semantic analyser

1
5. The ________ phase converts an intermediate code into an optimized code
that takes lesser space and lesser time to execute. [2]
A. Code optimization
B. Syntax directed translation
C. Code generation
D. Intermediate code generation
6. _________ is invoked whenever any fault occurs in the compilation process
of source program. [2]
A. Syntax analyser
B. Code generator
C. Error handler
D. Lexical analyser

7. In Compiler, the activities of one or more phases are combined into a


single module known as ________. [1]
A. Phase
B. Pass
C. Token
D. Macro

8.For the construction of a compiler the compiler writes uses different


types of software tools that are known as [1]
A. Compiler writer tools
B. Programming tools
C. Compiler construction tools
D. None of these

9. A compiler that runs on one machine and produces the target code for
another machine is known as ________. [1]
A. Cross Compiler
B. Linker
C. Preprocessor
D. Assembler

2
10.A _________ acts as an interface between the source program and the rest
of the compiler phase of the compiler. [1]
A. Semantic Analyzer
B. Parser
C. Lexical analyser
D. Syntax analyser
11. Which of the tasks are performed by the lexical analyser? [2]
A. Stripping out comments and whitespace
B. Correlating error messages with the source program
C. Performing the expansion of macros
D. All of these

12.A ________ is any finite set of strings over some specific alphabet. [1]
A. Sentence
B. Word
C. Language
D. Character class

13. If zero or more symbols are removed from the end of any string s, a new
string is obtained known as a __________of string s. [2]
A. Prefix
B. Suffix
C. Substring
D. Subsequence

14. If we have more than one possible transition on the same input symbol
from some state, then the recognizer is said to be [2]
A. Non-deterministic finite automata
B. Deterministic finite automata
C. Finite automata
D. None of these

3
15. A tool for automatically generating a lexical analyser for a language
is defined as _______. [1]
A. Lex
B. YACC
C. Handler
D. All of these

16. for a=10 to 50, in the given code, a is defined as a/an [1]
A. Constant
B. Identifier
C. Keyword
D. Operator

17. The language for C identifier can be described as :letter_(letter_|


digit)*, here * indicates [1]
A. Union
B. Zero or more instances
C. Group of subexpressions
D. Intersection

18. A _________ is a compact notation that is used to represent the patterns


corresponding to a token. [1]
A. Transition Diagram
B. Regular Expression
C. Alphabet
D. Input buffer

19. The number of tokens in the following C statement is


printf("i = %d, &i = %x", i, &i); [2]
A. 3
B. 26
C. 10
D. 21

4
20. In a compiler, keywords of a language are recognized during [1]
A. parsing of the program
B. the code generation
C. the lexical analysis of the program
D. dataflow analysis
21. Consider the following statements: [1]
(I) The output of a lexical analyser is groups of characters.
(II) Total number of tokens in printf("i=%d, &i=%x", i, &i); are 11.

(III) Symbol table can be implementation by using array and hash table but
not tree.
Which of the following statement(s) is/are correct?
A.Only (I)
B.Only (II) and (III)
C.All (I), (II), and (III)
D.None of these

22. Which one of the following statements is FALSE? [1]

A. Context-free grammar can be used to specify both lexical and syntax


rules.

B. Type checking is done before parsing.

C. High-level language programs can be translated to different Intermediate


Representations.

D. Arguments to a function can be passed using the program stack.

23. The output of a lexical analyser is [1]


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

5
24. Consider the following statements related to compiler construction: [1]
I. Lexical Analysis is specified by context-free grammars and implemented
by pushdown automata.
II. Syntax Analysis is specified by regular expressions and implemented by
finite-state machine.
Which of the above statement(s) is/are correct?
A. Only I
B. Only II
C. Both I and II
D. Neither I nor II

25. Which of the following statement(s) regarding a linker software is/are


true? [1]

I. A function of a linker is to combine several object modules into a single


load module.

II. A function of a linker is to replace absolute references in an object


module by symbolic references to locations in other modules.

A. Only I
B. Only II
C. Both I and II
D. Neither I nor II
26.The number of tokens in the following C statement is [1]
printf("i=%d, &i=%x", i&i);
A.13
B.6
C.10
D.9
27. A language L from a grammar G = { V N, Σ, P, S} is? [1]
A. Set of symbols over VN
B. Set of symbols over Σ
C. Set of symbols over P
D. Set of symbols over S

6
28. What is the transitional function of a DFA? [1]
A. Q X Σ→Q
B. Q X Σ→2Q
C. Q X Σ→2n
D. Q X Σ→Qn

29.A finite automata recognize ____________ [1]


A. Any Language
B. Context Sensitive Language
C. Context Free Language
D. Regular Language

30. The Tuples for NDFA is ___________ [2]


A. ∑, Q, q0, F, δ
B. Q, q0, F, δ
C. Θ, Q, q0, F,δ
D. F, Q, Δ, q0, δ

31.For which of the following reasons, a compiler is preferable to an


interpreter? [2]

A. It can generate stand-alone programs that often take less time for
execution

B. It is much helpful in the initial stages of program development

C. Debugging can be faster and easier

D. It needs less computer resources

32. Cross-compiler is a compiler [2]

A. which is written in a language that is different from the source language

B. that generates object code for its last machine

C. which is written in a language that is same as the source language

D. that runs on one machine but produces object code for another machine

7
33. Whether a given pattern constitutes a token or not [1]
A. depends on the source language
B. depends on the target language
C. depends on the compiler
D. none of the above comment is true

34. In a compiler, grouping of characters into tokens is done by the [1]


A. scanner
B. parser
C. code generator
D. code optimizer

35. Lexeme is [2]


A. a sequence of characters in the source program that is matched by the
pattern of a token
B. always same as token
C. terminal of a grammar
D. non-terminal of a grammar

36. Pattern is [2]


A. a rule which describes a set of string in input for which the same token
is produced as output

B. rule to generate grammar


C. a rule to generate a language,
D. a rule to create a program

37. Token is [2]


A. terminal symbol in a grammar
B. non-terminal symbol in a grammar
C. both a and b
D. none of these

8
38. The regular expression for the language of all strings that have zero
or more a’s followed by zero or more b’s is [2]

A. ( a + b )

B. abc

C. a*b*

D. (ab)+

39. In some phase of compiler [2]


Input :
temp1 := int to real(60)
temp2 :=id3*temp1
temp3 :=id2*temp2
id1 :=temp3
Output:
temp1 :=id3*60.0
id1:=id2+temp1
where temp1, temp2, temp3 are temporary storage , id1, id2, id3 are
identifier “int to real” is converting int 60 to real number
The above phase is ,
A. code optimizer
B. code generator
C. intermediate code generator
D. syntax analysis

40. What is not the phase of a compiler? [1]


A. syntax analyser
B. code generator
C. code optimizer
D. code linker

9
41. Which one of the following is CORRECT? [2]
I. If all states of an NFA are accepting
states then the language accepted by
the NFA is Σ∗.
II. There exists a regular language A such that it is also CFG

A.I is true
B.II is true
C.Both of them
D.None Of the Above

42.The number of states in the minimal deterministic finite automaton


corresponding to the regular expression (0+1)^∗(10) is _____. [2]

A. 1
B. 2
C. 3
D. 4

43. Which Of these statements is correct? [2]

I. Java is an interpreted language


II.
Lexical Analysis can be done through D-PDA

A.I is true
B.II is true
C.Both of them
D.None Of the Above

44.How many DFA's exist with two states over the input alphabet {0,1}? [2]
A. 128
B .64
C. 2
D. 4

10
45.How many DFA's exist with two states over the input alphabet {0,1} with
Designated Initial State? [2]
A. 128
B . 64
C. 2
D. 4

46.Match the Following: [1]


(P) Lexical Analysis (I)Left Most Derivation
(Q) Top Down Parsing (II)Type Checking
(R) Semantic Analysis (III)Regular Expression
(S) Run Time Environment (IV) Activation record

A. P-III,Q-I,R-II,S-IV
B. P-II,Q-III,R-I,S-IV
C. P-III,Q-I,R-II,S-III
D. None of the Above

47. Which of the following have not performed during Compilation? [1]
A. memory allocation in Heap
B. type casting.
C. Symbol Table Updation
D. mismatching the syntax

48. For this declaration which error will come? [1]


for(i=0,i<n,i++);
A. Syntax Error
B. Linking Error
C. Loading Error
D. for is an expected error.

11
49.Consider P is a Program having two modules m1,m2
m1 uses m2 extensively but they are belonging from different files. At which
Step this Problems can be solved? [1]
A. Linking Time
B. Loading Time
C. Semantic Analysis time
D. None Of the Above
50. Lexeme is--> [1]
A. a sequence of characters in the source program that is matched by the
pattern of a token
B. always same as token
C. terminal of a grammar
D. non-terminal of a grammar

51.Symbol table can be made through for optimal look up? [1]

A. 2 D array having lower triangular format and ordered

B. Min Heap

C. Hash Table

D. Linearly Ordered such that binary search can be performed

52.which one is correct? [1]

A. r* = r(*)

B. r* = r^+ iff r=epsilon

C. (r*)* = { }

D. r* - {} = {}

53.To Understand an Identifier what is the specific identifier? [1]

A. L(L+D)^*

B. L(L+D)

C. L(L)

D. D(L)

12
54. [1]
fi(i<=0){
some instructions
}
Which error will occur?

A. Lexical Error

B. Syntax Error

C. Linking Error

D. Loading Error

55. [1]
fi(i<=0);
Which Error will Occur?

A. Lexical Error

B. Syntax Error

C. Linking Error

D. Loading Error

56. [1]
while(i>=0);
this error can occur in which state?

A. Linking error

B. Syntax Error

C. No error

D. Error not in Compilation

57. Lexical Analyzer can be Developed through? [1]

A. epsilon NFA

B. Lexical analysis

C. Dynamic way

D. Branch and Bound

13
58.Given for all Regular Languages [2]
1. "DFA is a Proper Subset of NFA"
2. " DFA is a Subset of NFA "
Which one is Correct?

A. 1 is True, 2 is False

B. 1 is True, 2 is True

C. 1 is False, 2 is True

D. None

59.After Compilation of a Java Code what is formed? [1]

A. Byte Code

B. .class file

C. .exe file

D. None of the above

60.Dividing by Zero can be evaluated in which state? [1]

A. Semantic analysis

B. ICG

C. Run time

D. Code Optimization

61. [1]
int _=1;
For this Statement the error will generate where?

A. No error

B. Lexical error

C. Syntax error

D. Run time error

14
62.McNaughton-Yamada-Thompson is an Algorithm used for which purpose? [2]

A. Converting reg. expression to NFA

B. Converting NFA to DFA

C. Converting DFA to PDA

D. None of the above

63.Who Produces "Syntax Tree" ? [1]

A. Parser

B. Lex

C. Synthesizer

D. None

64.Type checking is normally done during [1]

A. Syntax Analysis

B. Lexical Analysis

C. Code optimization

D. Syntax Directed translation

65.The Pattern to identify "Identifier" can be implemented by [2]

A. Linear Bounded Automata (LBA)

B. Turing Machine

C. Both

D. LBA can’t be used

66.Which of the following are Lexemes? [1]

A. Identifiers

B. Constants

C. Keywords

D. All of the mentioned

15
67.Linear analysis is called ____ in a compiler. [1]

A. Lexical analysis

B. Scanning

C. Testing

D. Both a and b

68. [2]

1.All tokens are Lexem

2.All lexem are tokens

Which of the following options is true?

A. 1 is true

B. 2 is true

C. Both are same

D. None of the above

69. [1]
int a,b;
a = 1,2,3;
the error is generated in which state?

A. No error is there

B. Syntax Analysis

C Run Time

D. Lexical Analysis

16
70. [1]
int a,b=1,2,3,4,5;
the error is generated in which state?

A. No error is there

B. Syntax Analysis

C. Run Time

D. Lexical Analysis

71. Code Optimisation is a state of [1]

A. Compilation

B. Linking

C. Loading

D. Pre-processing state

72.Which of the following is not a Part of Compiler? [1]

A. Preprocessing

B. Lexical Analysis

C. Syntax Analysis

D. None

73.
Which of the Following Language uses Interpreter only? [1]

A. Java

B. C

C. C++

D. Ruby

17
74.A compiler capable of creating executable code for a platform other than
the one on which the compiler is running. [1]
This type of Compiler is said as =>

A. Cross Compiler

B. Multi way Compiler

C. MUlti threaded compiler

D. Compiled compiler

75. Wide Compiler is also known as [1]

A. Multi Pass Compiler

B. Criss cross Compiler

C. Compiled Compiler

D. Interpreter

76. Grammar of a Programming Language is verified in which state? [1]

A. Syntax Analysis

B. Semantic Analysis

C. Lexical Analysis

D. None of the Above

77.The process of finding the Parse tree for a String of tokens is called?
[2]
A. Parsing

B. Lexing

C. Finding

D. none of the above

18
78.Compiler can Check which type of error? [1]

A. Logical

B. Syntactical

C. Essential

D. all of the above

79. Who converts the High-Level Language to Lower Level Language [2]

A. Compiler

B. SUPER editor

C. Editor

D. None of the above

80.Which type of Compiler takes less memory? [1]

A. Multi Pass Compiler

B. Two Pass Compiler

C. Single Pass Compiler

D. None

81.A program that translates from a low-level language to a higher level one
is a [1]

A. Decompiler

B. Recomipler

C. Reverse Compiler

D. Redo Compiler

82.From Lexical Analysis to Machine dependent Code Optimisation known as [1]

A. Front End

B. Back End

C. Intermediate

D. None of the above

19
83.A software development tool used mainly in the construction of compilers,
translators, and interpreters for other programming languages.is known as
[2]
A. Meta Compiler

B. Beta Compiler

C. Source

D. src

84.Blank Spaces is removed in [1]

A. Lexical Analysis

B. Syntax Analysis

C. Pre-processing

D. None

85. Comment Section is remove in [1]

A. Lexical Analysis

B. Syntax Analysis

C. Pre-processing

D. None

86.Macros are replaced [1]

A. After Compilation

B. Before Compilation

C. At the time Compilation

D. Error

87. The Language in which the Programming structures are written? [2]

A. BNF

B. CNF

C. FA

D. LBA

20
88. "Lex" is a tool for [1]

A. Lexical Analysis

B. Syntax Analysis

C. Semantic Analysis

D. None.

89. "YACC" is a compiler for [1]

A. Semantic analysis

B. Syntax Analysis

C. Both can use

D. None of the Above

90.Back End states are [1]

A. Platform Dependent

B. Platform Independent

C. Both

D. None of the above

91.Front End states are [1]

A. Platform Dependent

B. Platform Independent

C. Both

D. None of the above

92.Target Code generation is [1]

A. Platform Dependent

B. Platform Independent

C. Both

D. None of the above

21
93.Lexical Analysis [1]

A. Platform Dependent

B. Platform Independent

C. Both

D. None of the above

94.Syntax Analysis [1]

A. Platform Dependent

B. Platform Independent

C. Both

D. None of the above

95.Let N be an NFA with n states. Let k be the number of states of a minimal


DFA which is equivalent to N. Which one of the following is necessarily
true? [2]

A. k ≤ 2n

B. k ≥ 2^n

C. K =n

D. none

96. [2]
Language L1 is defined by the grammar: S1 → aS1b|ε

Language L2 is defined by the grammar: S2 → abS2|ε

Consider the following statements:

P:L1 is regular
Q: L2 is regular
Which one of the following is TRUE?

A. P is true , Q is false

B. P is False , Q is True

C. Both are true

D. Both are False

22
97.NFA is a Proper Subset of [1]

A. PDA

B. DFA

C. both

D. None of the above

98.Regular Languages can be accepted by [1]

A. DFA

B. NFA

C. PDA

D. all of the above

99. The Subset of Regular set is always [1]

A. Regular

B. Irregular

C. Context Free Grammar

D. None of the above

100.Infinite Union of Regular Language is [1]

A. Regular

B. accepted by DFA

C. accepted by NFA

D. None of the above

***---***

23

You might also like