Question 1 | MCQ
THIS IS QUESTION PAPER FOR THE SUBJECT "DEGREE LEVEL : COMPILER DESIGN (COMPUTER
BASED EXAM)"
ARE YOU SURE YOU HAVE TO WRITE EXAM FOR THIS SUBJECT?
CROSS CHECK YOUR HALL TICKET TO CONFIRM THE SUBJECTS TO BE WRITTEN.
(IF IT IS NOT THE CORRECT SUBJECT, PLS CHECK THE SECTION AT THE TOP FOR THE SUBJECTS REGISTERED BY YOU)
BASED EXAM)"
ARE YOU SURE YOU HAVE TO WRITE EXAM FOR THIS SUBJECT?
CROSS CHECK YOUR HALL TICKET TO CONFIRM THE SUBJECTS TO BE WRITTEN.
(IF IT IS NOT THE CORRECT SUBJECT, PLS CHECK THE SECTION AT THE TOP FOR THE SUBJECTS REGISTERED BY YOU)
Solution
Consider the following compiler phases and compiler tasks.

Which one of the following correctly matches the compiler phases with their primary tasks?
Which one of the following correctly matches the compiler phases with their primary tasks?
Solution
Which of the following describes a key programmatic difference between the functionality of an Interpreter and a Compiler toolchain?
Solution
A compiler detects that the variable
is used before it is declared in a program.
Which compiler phase is primarily responsible for reporting this error?
Which compiler phase is primarily responsible for reporting this error?
Solution
A C program contains a function-like macro
.
During a code audit, a developer encounters the statement
.
Which of the following statements correctly evaluates how the preprocessor handles this, and what the final value of
will be after execution?
During a code audit, a developer encounters the statement
Which of the following statements correctly evaluates how the preprocessor handles this, and what the final value of
Solution
A compiler architecture uses a common Intermediate Representation (IR). Initially, it supports 6 source languages and 4 target architectures.
Later, support for 3 new source languages and 2 new target architectures is added.
Without using IR, the compiler requires one translator for every source-target pair.
With IR, how many fewer translators/components are required after the expansion?
Later, support for 3 new source languages and 2 new target architectures is added.
Without using IR, the compiler requires one translator for every source-target pair.
With IR, how many fewer translators/components are required after the expansion?
Solution
Which of the following is NOT a responsibility of the lexical analyzer?
Solution
A lexical analyzer processes the following input.

The token specifications are listed in this order.

The lexer follows both the Longest Match Rule and the Earlier Matching Rule.
Which token sequence is generated?
The token specifications are listed in this order.
The lexer follows both the Longest Match Rule and the Earlier Matching Rule.
Which token sequence is generated?
Solution
Consider the regular expression

Which of the following best describes the language of
?
Which of the following best describes the language of
Solution
A programmer writes a Lex specification in a file named
. Which of the following correctly describes the sequence of steps required to obtain an executable lexical analyzer?
Solution
Which of the following statements correctly describes machine-independent optimizations?
Solution
Inscript
Consider the following declarations:

The compiler generates Three-Address Code (TAC) for the statement

Assume the following:
- Integer arithmetic is performed whenever all operands are integers.
- If an arithmetic operation involves both
and
, all operands are first converted to
.
-
converts an
to a
.
-
converts a
to an
.
- The compiler generates the minimum number of explicit type-conversion instructions.
Ignoring all arithmetic and assignment instructions, how many explicit type-conversion instructions are required?
Consider the following declarations:
The compiler generates Three-Address Code (TAC) for the statement
Assume the following:
- Integer arithmetic is performed whenever all operands are integers.
- If an arithmetic operation involves both
-
-
- The compiler generates the minimum number of explicit type-conversion instructions.
Ignoring all arithmetic and assignment instructions, how many explicit type-conversion instructions are required?
Solution
A compiler generates the following Three-Address Code (TAC) to compute the final bill amount after adding a fixed service charge to the item price.
The compiler then applies the following optimizations in order:
1. Constant Folding
2. Copy Propagation
3. Dead Code Elimination

Which of the following is the optimized TAC?
The compiler then applies the following optimizations in order:
1. Constant Folding
2. Copy Propagation
3. Dead Code Elimination
Which of the following is the optimized TAC?
Solution
Solution
A compiler generates the following Abstract Syntax Tree (AST) for an expression.

Which of the following Three-Address Code (TAC) sequences correctly represents the AST?
Which of the following Three-Address Code (TAC) sequences correctly represents the AST?
Solution
A compiler performs lexical analysis and stores:
- every unique identifier in the Symbol Table,
- every unique integer constant in the Constant Table.
Keywords, operators, delimiters, and punctuation symbols are not stored in either table.
Consider the following program.

How many entries will be present in the Symbol Table and the Constant Table, respectively?
- every unique identifier in the Symbol Table,
- every unique integer constant in the Constant Table.
Keywords, operators, delimiters, and punctuation symbols are not stored in either table.
Consider the following program.
How many entries will be present in the Symbol Table and the Constant Table, respectively?
Solution
Consider the following Deterministic Finite Automaton (DFA)
, where:
-
-
- Start state:
- Final states:
The transition diagram is given below

Assume that any undefined transition leads to a dead (trap) state, which is not shown in the table.
Which of the following regular expressions describes the language accepted by the DFA?
-
-
- Start state:
- Final states:
The transition diagram is given below
Assume that any undefined transition leads to a dead (trap) state, which is not shown in the table.
Which of the following regular expressions describes the language accepted by the DFA?
Solution
Inscript
A compiler back-end generates the following Three-Address Code (TAC) for an image
enhancement algorithm.

Assume that:
-
,
,
,
,
,
,
,
, and
are read directly from memory.
- Only the compiler-generated temporaries (
–
) occupy hardware registers.
- A temporary remains live from the instruction where it is defined until its last use.
- Instructions are executed strictly in the given order.
What is the maximum number of compiler-generated temporaries that are simultaneously live during the execution of the above TAC?
A compiler back-end generates the following Three-Address Code (TAC) for an image
enhancement algorithm.
Assume that:
-
- Only the compiler-generated temporaries (
- A temporary remains live from the instruction where it is defined until its last use.
- Instructions are executed strictly in the given order.
What is the maximum number of compiler-generated temporaries that are simultaneously live during the execution of the above TAC?
Solution
Consider the following Deterministic Finite Automaton (DFA)

where
-
-
- Start state:
- Accepting states:
The transition function
is given below.

Which of the following strings are accepted by the DFA?
where
-
-
- Start state:
- Accepting states:
The transition function
Which of the following strings are accepted by the DFA?
Solution
Consider the following statements about Deterministic Finite Automata (DFA) and Nondeterministic Finite Automata (NFA).
Which of the following statement(s) is/are correct?
Which of the following statement(s) is/are correct?
Solution
Shape
Thickness [ / ]
3
All colors