Compiler Design | Questions and Answers

Compiler Design | Mock Test

Question 1
An ideal Compiler should
Select one:
A. Be smaller in size
B. Takes less time for compilation
C. Be written in a high level language
D. All of the above

Feedback
The correct answer is: All of the above

Question 2
For which of the following reason, a compiler is preferred to a interpreter
Select one:
a. It can generate stand-alone programs and often takes less time for execution
b. Debugging can be faster and easier
Feedback
The correct answer is: It can generate stand-alone programs and often takes less time for execution

Question 3
For which of the following reason, a compiler is preferred to a interpreter
Select one:
a. It can generate stand-alone programs and often takes less time for execution
b. Debugging can be faster and easier
Feedback
The correct answer is: It can generate stand-alone programs and often takes less time for execution

Question 4
To design LL parser the grammar should be free from left recursion
Select one:
a. True
b. False
Feedback
The correct answer is ‘True’.

Question 5
In a compiler, grouping of characters into tokens is done by the
Select one:
a. Code optimizer
b. Parser
c. Code generator
d. Scanner
Feedback
The correct answer is: Scanner

Question 6
In a context free grammar
Select one:
A. ε can not be the right hand side of any production
B. Terminal symbols can not be present in the left hand side of any production
C. The number of grammar symbols in the LHS is not greater than the number of grammar symbols in the RHS
D. All of the above
Feedback
The correct answer is: Terminal symbols can not be present in the left hand side of any production

Question 7
Remove flag
The main difference between DFA and NDFA
Select one:
a.
In DFA from any given state there cannot be any alphabet leading to two different states
b. In NDFA empty transition may be present
c. In NDFA from any given state there cannot be any alphabet leading to two different states
d. In DFA empty transition may be present
Feedback
The correct answer is:
In DFA from any given state there cannot be any alphabet leading to two different states

Question 8
A syntax tree
Select one:
a. generates tokens
b. Another name of the parse tree
c. Should not have keywords as leaves
d. Is a condensed form of grammar
Feedback
The correct answer is: Another name of the parse tree

Question 9
Regular expression letter ( letter | digit)* can be used to recognise set of valid identifiers.
Select one:
a. True
b. False
Feedback
The correct answer is ‘True’.

Question 10
Construction of DFA is easy and implementation of DFA is difficult
Select one:
a. True
b. False
Feedback
The correct answer is ‘True’.