Skip to content
- Which of the following is the first phase of compilation?
a) Code Generation
b) Lexical Analysis
c) Syntax Analysis
d) OptimizationAnswer: b) Lexical Analysis
- In which phase of the compilation process are syntax errors detected?
a) Lexical Analysis
b) Syntax Analysis
c) Code Generation
d) Semantic AnalysisAnswer: b) Syntax Analysis
- What is the role of the semantic analysis phase in compilation?
a) To check for errors in the syntax of the source code
b) To assign memory addresses to variables
c) To ensure the meaning of the program is valid, such as type checking
d) To optimize the codeAnswer: c) To ensure the meaning of the program is valid, such as type checking
- What does the intermediate code generation phase do?
a) Converts the source code directly into machine code
b) Converts the source code into an intermediate form for further optimization
c) Converts the program into a human-readable form
d) Executes the program immediatelyAnswer: b) Converts the source code into an intermediate form for further optimization
- Which of the following is the primary function of the code generation phase?
a) Translate the program into an intermediate code
b) Convert the intermediate code into machine code
c) Optimize the code
d) Check for semantic errors in the codeAnswer: b) Convert the intermediate code into machine code
- Which phase of the compiler handles error detection and reporting related to program semantics?
a) Lexical Analysis
b) Syntax Analysis
c) Semantic Analysis
d) OptimizationAnswer: c) Semantic Analysis
- In which phase does the compiler generate the final machine-level code?
a) Lexical Analysis
b) Syntax Analysis
c) Code Generation
d) OptimizationAnswer: c) Code Generation
- The optimization phase of compilation is concerned with:
a) Checking for syntax errors
b) Making the code more efficient without changing its behavior
c) Converting source code into machine code
d) Assigning variable typesAnswer: b) Making the code more efficient without changing its behavior
- Which phase is responsible for breaking the input program into tokens?
a) Syntax Analysis
b) Lexical Analysis
c) Code Generation
d) OptimizationAnswer: b) Lexical Analysis
- In which phase are the final machine instructions selected and arranged for execution?
a) Lexical Analysis
b) Syntax Analysis
c) Code Generation
d) Intermediate Code GenerationAnswer: c) Code Generation