FreeExam
A closed notebook, a blank card, and a pencil on a wooden desk.

Compiler engineer

Free interview questions with answers and explanations

5 topics · 505 questions

Preserve program meaning through analysis, optimization, code generation, and runtime boundaries.

Mid level

Sample questions with answers

Try these original Compiler practice questions, then read the worked explanations. Open a topic for the full question bank.

Program analysis and optimization correctness

A language permits both a one-character greater-than token and a two-character greater-than-or-equal token. What must its lexer use to distinguish adjacent input characters correctly?

  1. The eventual machine register count
  2. Only the number of spaces in the whole file
  3. The parser's final optimization level
  4. The language's tokenization rules

Answer: The language's tokenization rules

Explanation: Token boundaries follow lexical rules, including how overlapping token forms are recognized. Later code generation cannot repair an incorrectly tokenized source stream.

Compiler engineer: Code Generation and Runtime

A backend maps an IR operation to a target instruction. What must selection preserve?

  1. Opcode spelling
  2. The fewest instructions regardless of effects
  3. Required IR results and effects
  4. The original virtual-register order

Answer: Required IR results and effects

Explanation: Instruction selection must implement the relevant value and effect behavior.

Compiler engineer: Frontends and Type Systems

A lexer treats comment markers inside quoted strings as comments. What boundary is wrong?

  1. Lexical state handling
  2. Longest-token preference
  3. Identifier scope resolution
  4. Token-buffer capacity

Answer: Lexical state handling

Explanation: Token recognition must respect whether the scanner is inside a string.