Compiler Design - Practice Set 2
Compiler Design - Practice Set 2
12. Which of the following is a part of a compiler that takes as input a stream of characters and
produces as output a stream of words along with their associated syntactic categories?
a) Optimizer
b) Scanner
c) Parser
d) None of the mentioned
Answer: b
Explanation: A compiler’s scanner scans a character-based input stream and creates a word-based
output stream, with each word identified with its Syntactic category.
20. An object module for a group of programs that were compiled separately is handed to a linker.
Which of the following about an object module isn’t true?
a) Relocation bits
b) Names and locations of all external symbols denied in the object module
c) Absolute addresses of internal symbols
d) Object code
Answer: c
Explanation: A linker, sometimes known as a link editor, is a computer program that merges one or
more object files generated by a compiler into a single executable, library, or another object file.
21. Characters are grouped into tokens in which of the following phase of the compiler design?
a) Code generator
b) Lexical analyzer
c) Parser
d) Code optimization
Answer: b
Explanation: Gives tokens as output
22. Why Generation of intermediate code based on an abstract machine model is useful in compilers?
a) Writing for intermediate code generation
b) Portability of the front end of the compiler
c) Implementation of lexical analysis and syntax analysis is made easier
d) All of the mentioned
Answer: c
Explanation: Intermediate code generator receives input from its predecessor phase, semantic analyzer,
in the form of an annotated syntax tree.
24. Which of the following technique is used for building cross compilers for other machines?
a) Canadian Cross
b) Mexican Cross
c) X-cross
d) Brazilian Cross
Answer: a
Explanation: The Canadian Cross is a technique for building cross compilers for other machines. Given
three machines X, Y, and Z, one uses machine X (e.g. running Windows XP on an IA-32 processor) to
build a cross compiler that runs on machine Y (e.g. running Mac OS X on an x86-64 processor) to create
executables for machine Z.
25. Which of the following can detect an error if a programmer by mistake writes multiplication instead
of division?
a) Interpreter
b) Compiler or interpreter test
c) Compiler
d) None of the mentioned
Answer: d
Explanation: No Logical errors can’t be detected.