Compilers Questions and Answers – Three-Address Statements – 1


This set of Compilers Multiple Choice Questions & Answers (MCQs) focuses on “Three-Address Statements”.

1. Which languages necessarily need heap allocation in the runtime environment?
a) Those that support recursion
b) Those that use dynamic scoping
c) Allow dynamic data structure
d) Those that use global variables
View Answer

Answer: c
Explanation: E.g.: Heap .

2. Given the language L-{ab, aa, baa}, which of the following strings are in LG?
1) abaabaaabaa
2) aaaabaaaa
3) baaaaabaaaab
4) baaaaabaa
a) 1,2 and 3
b) 2,3 and 4
c) 1,2 and 4
d) 1,3 and 4
View Answer

Answer: c
Explanation: generates strings like aaaabaaaa

3. A simple two-pass assembler does which of the following in the first pass
a) Space for the literals
b) Total length of the program
c) It builds the symbol table for the symbols and their values.
d) All of the mentioned
View Answer

Answer: d
Explanation: the two pass assembler allocates space for literals as well as calculates table length and also builds the symbol table

4. _________ 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
b) Diversion
c) Modelling
d) None of the mentioned
View Answer

Answer: a
Explanation: Takes input strings and gives tokens as output

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

Answer: d
Explanation: Gives tokens as output

6. 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 mentioned
View Answer

Answer: a
Explanation: Lexical analyser takes source program as input and token as output

7. The action of parsing the source program into proper syntactic classes is called
a) Syntax analysis
b) Lexical analysis
c) Interpretation analysis
d) General syntax analysis
View Answer

Answer: b
Explanation: checks for correct syntax


8. Task of the lexical analysis
a) None of the mentioned
b) To build a literal and identifier table
c) To build a uniform symbol table
d) Both
View Answer

Answer: d
Explanation: It is the task performed

9. The output of lexical analyzer is A
a) Set of regular expressions
b) Syntax tree
c) Set of tokens
d) Strings of character
View Answer

Answer: c
Explanation: Tokens is the output of a lexical analyser

10. The output of a lexical analyzer is
a) Machine code
b) Intermediate code
c) Stream of tokens
d) Parse tree
View Answer

Answer: c
Explanation: Set of tokens is given as an output

Sanfoundry Global Education & Learning Series – Compilers.
To practice all areas of Compilers, here is complete set of 1000+ Multiple Choice Questions and Answers.

Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn