Compiler Design MCQ
Our website offers a comprehensive collection of Compiler Design MCQs to help learners understand key concepts in compiler development. Topics include lexical analysis, syntax analysis, parsing, code optimization, error handling, and code generation. Each question includes detailed explanations to support effective learning and exam preparation. Suitable for students, professionals, and interview candidates, Our platform makes mastering compiler design easy, interactive, and practical for academic and career success.
Q1. Which phase of the compiler checks the syntax of the source code?
A. Lexical analysis
B. Syntax analysis
C. Semantic analysis
D. Code generation
📘 View Explanation
Q2. The first phase of a compiler is:
A. Lexical analysis
B. Syntax analysis
C. Intermediate code generation
D. Optimization
📘 View Explanation
Q3. Which data structure is commonly used in lexical analysis?
A. Stack
B. Queue
C. DFA
D. Tree
📘 View Explanation
Q4. Semantic analysis in a compiler checks:
A. Grammar rules
B. Type consistency and meaning
C. Token patterns
D. Machine code
📘 View Explanation
Q5. Intermediate code generation helps in:
A. Machine independence
B. Faster parsing
C. Direct execution
D. Token creation
📘 View Explanation
Q6. Which of the following is a bottom-up parsing technique?
A. LL(1) parsing
B. Recursive descent parsing
C. LR parsing
D. Predictive parsing
📘 View Explanation
Q7. The symbol table in a compiler is used for:
A. Storing tokens
B. Storing identifiers and attributes
C. Optimizing code
D. Generating errors
📘 View Explanation
Q8. Which phase of compiler is responsible for register allocation?
A. Lexical analysis
B. Syntax analysis
C. Code optimization
D. Code generation
📘 View Explanation
Q9. Which of the following parsing methods uses lookahead symbols?
A. Recursive descent
B. LL(1)
C. LR(0)
D. Shift-reduce
📘 View Explanation
Q10. Peephole optimization is applied in which phase?
A. Lexical analysis
B. Syntax analysis
C. Intermediate code generation
D. Code optimization
📘 View Explanation
Q11. Which parsing technique is known as top-down parsing?
A. LR parsing
B. SLR parsing
C. LL parsing
D. Operator precedence parsing
📘 View Explanation
Q12. A compiler that translates high-level language into assembly language is called:
A. Cross compiler
B. One-pass compiler
C. Source-to-source compiler
D. Assembler
📘 View Explanation
Q13. Which grammar is used for syntax analysis in compilers?
A. Regular grammar
B. Context-free grammar
C. Unrestricted grammar
D. Type-0 grammar
📘 View Explanation
Q14. In lexical analysis, removing white spaces and comments is called:
A. Parsing
B. Preprocessing
C. Lexeme recognition
D. Lexical cleanup
📘 View Explanation
Q15. Which of the following is NOT a type of intermediate code representation?
A. Three-address code
B. Quadruples
C. Postfix notation
D. Binary machine code
📘 View Explanation
Q16. Which parser is used by most modern compilers?
A. Recursive descent
B. LR parser
C. LL parser
D. Operator precedence parser
📘 View Explanation
Q17. Which type of errors are detected during lexical analysis?
A. Type errors
B. Spelling errors of tokens
C. Syntax errors
D. Semantic errors
📘 View Explanation
Q18. Which phase of the compiler is responsible for type checking?
A. Lexical analysis
B. Syntax analysis
C. Semantic analysis
D. Code generation
📘 View Explanation
Q19. What is the main task of an assembler in the compilation process?
A. Convert machine code to assembly
B. Convert assembly code to machine code
C. Optimize assembly code
D. Generate tokens
📘 View Explanation
Q20. Which of the following best describes a cross compiler?
A. Compiler that runs on one machine but generates code for another machine
B. Compiler that compiles two languages at once
C. Compiler that optimizes across modules
D. Compiler that interprets source code
📘 View Explanation