quiz

Compiler Design

Compiler Design and Operation

1. What is the main function of a compiler?

  • A) Translate computer code from a low-level language to a high-level language
  • B) Translate computer code from a high-level language to a low-level language
  • C) Execute high-level programming instructions directly
  • D) Convert machine code into an executable program
B) Translate computer code from a high-level language to a low-level language Explanation

2. What is a compiler-compiler?

  • A) A program that translates machine code to high-level language
  • B) A program that produces compilers or parts of them
  • C) A program that optimizes machine-specific code
  • D) A program that interprets high-level language code
B) A program that produces compilers or parts of them Explanation

3. Which phase of the compiler is responsible for transforming source code into an intermediate representation (IR)?

  • A) Front end
  • B) Middle end
  • C) Back end
  • D) Code generation
A) Front end Explanation

4. Which of the following software translates low-level languages to higher-level ones?

  • A) Interpreter
  • B) Source-to-source compiler
  • C) Decompiler
  • D) Compiler-compiler
C) Decompiler Explanation

5. Which optimization technique is involved in the removal of code that never gets executed?

  • A) Constant propagation
  • B) Loop unrolling
  • C) Dead-code elimination
  • D) Inline expansion
C) Dead-code elimination Explanation

6. What is a bootstrap compiler?

  • A) A temporary compiler used to compile a more permanent or optimized compiler
  • B) A compiler that translates high-level language to machine code directly
  • C)  A compiler that produces code for a different operating system
  • D) A compiler that translates machine code to high-level language
A) A temporary compiler used to compile a more permanent or optimized compiler Explanation

7. Which of the following is NOT typically a phase in the compilation process?

  • A) Preprocessing
  • B) Lexical analysis
  • C) Machine code execution
  • D) Code optimization
C) Machine code execution Explanation

8. Why might a language feature require a compiler to perform more than one pass over the source code?

  • A) To reduce the size of the final executable
  • B) To handle forward declarations and other dependencies
  • C) To speed up the compilation process
  • D) To simplify the syntax analysis phase
B) To handle forward declarations and other dependencies Explanation

9. Which of the following languages is most commonly used for compiler development due to its low-level capabilities?

  • A) Java
  • B) C
  • C) Python
  • D) Ruby

10. Which compiler is known to generate OS-independent bytecode?

  • A) GCC
  • B) Clang
  • C) Visual C++
  • D) Java Compiler
D) Java Compiler Explanation