Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Chapter: 1
Q21:
Code translation must ensure that machine code executes ______ as the source.
A. Differently
B. Faster
C. Precisely the same
D. Intermittently
Correct Answer:
C
Chapter: 1
Q22:
Which component receives 10% weight in course grading?
A. Theory
B. Project
C. Exams
D. Quizzes
Correct Answer:
A
Chapter: 1
Q23:
Which tool is used to compile C programs into machine code?
A. GCC
B. MS Word
C. Photoshop
D. PowerPoint
Correct Answer:
A
Chapter: 1
Q24:
leave in assembly is used to ________.
A. Exit the loop
B. Return from function
C. Restore base pointer
D. Multiply variables
Correct Answer:
C
Chapter: 1
Q25:
The line "incl %eax" in assembly does what?
A. Decrements %eax
B. Increments %eax
C. Clears %eax
D. Loads memory address
Correct Answer:
B
Chapter: 1
Q26:
How many assembly lines are generated for the function `expr`?
A. 5
B. 10
C. 15
D. More than 15
Correct Answer:
D
Chapter: 1
Q27:
In context of compilers, the term 'semantics' refers to ________.
A. Syntax rules
B. Execution order
C. Meaning of constructs
D. Variable naming
Correct Answer:
C
Chapter: 1
Q28:
The function expr returns an expression based on which variable?
A. a
B. b
C. n
D. c
Correct Answer:
C
Chapter: 1
Q29:
Assembly code is more suitable for ________.
A. Humans
B. Hardware
C. Managers
D. Students
Correct Answer:
B
Chapter: 1
Q30:
The book "Compilers – Principles, Techniques and Tools" is authored by ______.
A. Aho, Sethi, Ullman
B. Tanenbaum, Woodhull
C. Dennis Ritchie, Ken Thompson
D. Andrew Ng
Correct Answer:
A
Chapter: 1
Q31:
Which register is used for base pointer in assembly?
A. %eax
B. %esp
C. %ebp
D. %edx
Correct Answer:
C
Chapter: 1
Q32:
The assembly instruction 'ret' is used to ________.
A. Start a function
B. Return from function
C. Multiply operands
D. Declare a variable
Correct Answer:
B
Chapter: 1
Q33:
Which component has the highest grading percentage in the course?
A. Theory
B. Homeworks
C. Project
D. Exams
Correct Answer:
C
Chapter: 1
Q34:
Understanding compilers helps in writing ______ code.
A. Slower
B. Unstructured
C. Better optimized
D. Buggy
Correct Answer:
C
Chapter: 1
Q35:
Which part of the code represents human-readable format?
A. Assembly
B. Hexadecimal
C. Source code
D. Object code
Correct Answer:
C
Chapter: 1
Q36:
Which language is NOT mentioned as a typical compiler source?
A. Java
B. FORTRAN
C. Python
D. Pascal
Correct Answer:
C
Chapter: 1
Q37:
An ideal translation algorithm for compilers ______.
A. Exists for all cases
B. Is easy to implement
C. Does not exist
D. Is trivial
Correct Answer:
C
Chapter: 1
Q38:
The translation process in compilers is handled through ________.
A. One single algorithm
B. Multiple passes
C. Single loop
D. Manual conversion
Correct Answer:
B
Chapter: 2
Q39:
What is the main advantage of a two-pass compiler?
A. Faster compilation
B. Less memory usage
C. Supports multiple front and back ends
D. Generates bytecode
Correct Answer:
C
Chapter: 2
Q40:
Which part of the compiler maps legal source code to intermediate representation?
A. Back end
B. Scanner
C. Parser
D. Front end
Correct Answer:
D