Computer MCQs

Compiler Design MCQs with Answer

Which phase of the compiler translates the high-level source code into intermediate code?
a) Lexical Analysis
b) Syntax Analysis
c) Semantic Analysis
d) Intermediate Code Generation

Correct Answer: d) Intermediate Code Generation

Which data structure is typically used for implementing the symbol table in a compiler?
a) Array
b) Linked List
c) Hash Table
d) Binary Search Tree

Correct Answer: c) Hash Table

Which phase of the compiler checks for the validity of the code in terms of the language syntax?
a) Lexical Analysis
b) Syntax Analysis
c) Semantic Analysis
d) Code Optimization

Correct Answer: b) Syntax Analysis

What does the lexer produce as output during the lexical analysis phase of compilation?
a) Parse Tree
b) Intermediate Code
c) Tokens
d) Symbol Table

Correct Answer: c) Tokens

What is the purpose of the semantic analysis phase in compiler design?
a) Generating intermediate code
b) Checking for lexical errors
c) Checking for syntactic errors
d) Checking for semantic errors

Correct Answer: d) Checking for semantic errors

Which of the following is not a type of parser used in compiler design?
a) Recursive Descent Parser
b) LL Parser
c) LR Parser
d) LD Parser

Correct Answer: d) LD Parser

What is the primary function of the syntax-directed translation scheme in compiler design?
a) Generating intermediate code
b) Translating syntax into semantic actions
c) Optimizing the generated code
d) Generating machine code

Correct Answer: b) Translating syntax into semantic actions

Which phase of the compiler resolves the references to the variables and checks their data types?
a) Lexical Analysis
b) Syntax Analysis
c) Semantic Analysis
d) Code Generation

Correct Answer: c) Semantic Analysis

What is the main goal of the code optimization phase in compiler design?
a) Reducing the size of the source code
b) Improving the efficiency of the generated code
c) Removing lexical errors
d) Resolving syntax errors

Correct Answer: b) Improving the efficiency of the generated code

Which of the following is not a property of compiler front end?
a) Lexical Analysis
b) Semantic Analysis
c) Intermediate Code Generation
d) Code Optimization

Correct Answer: d) Code Optimization

Which phase of the compiler is responsible for generating the Abstract Syntax Tree (AST)?
a) Lexical Analysis
b) Syntax Analysis
c) Semantic Analysis
d) Intermediate Code Generation

Correct Answer: b) Syntax Analysis

Which of the following statements about syntax-directed translation is true?
a) It generates intermediate code directly from the source code.
b) It translates the high-level source code into machine code.
c) It associates semantic actions with syntax productions.
d) It performs lexical analysis.

Correct Answer: c) It associates semantic actions with syntax productions.

Which of the following is not a part of the lexical analysis phase?
a) Tokenization
b) Identifying keywords
c) Parsing the source code
d) Removing comments

Correct Answer: c) Parsing the source code

What is the primary task of the symbol table in a compiler?
a) Tokenizing the input source code
b) Storing information about identifiers and their attributes
c) Generating machine code
d) Optimizing the code

Correct Answer: b) Storing information about identifiers and their attributes

Which phase of the compiler generates the target code from the intermediate code?
a) Lexical Analysis
b) Syntax Analysis
c) Semantic Analysis
d) Code Generation

Correct Answer: d) Code Generation

Which of the following is a top-down parsing technique?
a) LL Parser
b) LR Parser
c) SLR Parser
d) LALR Parser

Correct Answer: a) LL Parser

Which of the following is not a part of the lexical analysis phase?
a) Removing white spaces and comments
b) Identifying tokens
c) Generating intermediate code
d) Identifying literals

Correct Answer: c) Generating intermediate code

Which of the following is not an attribute of tokens generated during lexical analysis?
a) Token Type
b) Value
c) Lexeme
d) Scope

Correct Answer: d) Scope

Which phase of the compiler optimizes the intermediate code to produce efficient target code?
a) Lexical Analysis
b) Syntax Analysis
c) Semantic Analysis
d) Code Optimization

Correct Answer: d) Code Optimization

Which of the following is not a part of the semantic analysis phase?
a) Type Checking
b) Error Detection
c) Symbol Table Creation
d) Lexical Analysis

Correct Answer: d) Lexical Analysis

Which of the following parsing techniques can handle a larger class of grammars?
a) LL Parser
b) SLR Parser
c) LR Parser
d) LALR Parser

Correct Answer: c) LR Parser

What is the purpose of the lexer in compiler design?
a) Generating intermediate code
b) Converting source code into tokens
c) Translating source code into machine code
d) Optimizing code

Correct Answer: b) Converting source code into tokens

Which of the following is not a part of the semantic analysis phase?
a) Type Checking
b) Symbol Table Management
c) Syntax Checking
d) Intermediate Code Generation

Correct Answer: c) Syntax Checking

Which of the following is not a part of the syntax analysis phase?
a) Lexical Analysis
b) Syntax Checking
c) Semantic Analysis
d) Error Handling

Correct Answer: c) Semantic Analysis

What does the syntax analysis phase of the compiler produce as output?
a) Tokens
b) Abstract Syntax Tree
c) Intermediate Code
d) Symbol Table

Correct Answer: b) Abstract Syntax Tree

Which of the following parsing techniques is more efficient but less powerful?
a) LL Parser
b) SLR Parser
c) LR Parser
d) LALR Parser

Correct Answer: b) SLR Parser

Which phase of the compiler detects and reports errors in the source code?
a) Lexical Analysis
b) Syntax Analysis
c) Semantic Analysis
d) Error Handling

Correct Answer: d) Error Handling

Which of the following is not a part of the code generation phase?
a) Register Allocation
b) Instruction Selection
c) Syntax Analysis
d) Peephole Optimization

Correct Answer: c) Syntax Analysis

Which of the following is not a part of the lexical analysis phase?
a) Removing white spaces
b) Identifying keywords
c) Identifying literals
d) Parsing the source code

Correct Answer: d) Parsing the source code

Which of the following is not a part of the syntax analysis phase?
a) Lexical Analysis
b) Syntax Checking
c) Error Handling
d) Semantic Analysis

Correct Answer: d) Semantic Analysis

Which of the following is not an optimization technique used in the code optimization phase?
a) Dead Code Elimination
b) Constant Folding
c) Register Allocation
d) Lexical Analysis

Correct Answer: d) Lexical Analysis

Which phase of the compiler translates the source code into an intermediate representation?
a) Lexical Analysis
b) Syntax Analysis
c) Semantic Analysis
d) Intermediate Code Generation

Correct Answer: d) Intermediate Code Generation

Which phase of the compiler assigns types to the variables and expressions?
a) Lexical Analysis
b) Syntax Analysis
c) Semantic Analysis
d) Intermediate Code Generation

Correct Answer: c) Semantic Analysis

Which of the following parsing techniques is used in recursive descent parsing?
a) LL Parser
b) LR Parser
c) SLR Parser
d) LALR Parser

Correct Answer: a) LL Parser

Which of the following parsing techniques is used in the bottom-up parsing?
a) LL Parser
b) LR Parser
c) SLR Parser
d) LALR Parser

Correct Answer: b) LR Parser

Which of the following is not an attribute of tokens generated during lexical analysis?
a) Token Type
b) Value
c) Lexeme
d) Scope

Correct Answer: d) Scope

Which phase of the compiler checks whether the program follows the rules of the language?
a) Lexical Analysis
b) Syntax Analysis
c) Semantic Analysis
d) Intermediate Code Generation

Correct Answer: b) Syntax Analysis

Which of the following is not a part of the lexical analysis phase?
a) Tokenization
b) Identifying keywords
c) Parsing the source code
d) Removing comments

Correct Answer: c) Parsing the source code

Which of the following is not a property of compiler front end?
a) Lexical Analysis
b) Semantic Analysis
c) Intermediate Code Generation
d) Code Optimization

Correct Answer: d) Code Optimization

Which phase of the compiler generates the target code from the intermediate code?
a) Lexical Analysis
b) Syntax Analysis
c) Semantic Analysis
d) Code Generation

Correct Answer: d) Code Generation

Which of the following parsing techniques can handle a larger class of grammars?
a) LL Parser
b) SLR Parser
c) LR Parser
d) LALR Parser

Correct Answer: c) LR Parser

Which phase of the compiler is responsible for generating the Abstract Syntax Tree (AST)?
a) Lexical Analysis
b) Syntax Analysis
c) Semantic Analysis
d) Intermediate Code Generation

Correct Answer: b) Syntax Analysis

Which of the following is a top-down parsing technique?
a) LL Parser
b) LR Parser
c) SLR Parser
d) LALR Parser

Correct Answer: a) LL Parser

Which phase of the compiler optimizes the intermediate code to produce efficient target code?
a) Lexical Analysis
b) Syntax Analysis
c) Semantic Analysis
d) Code Optimization

Correct Answer: d) Code Optimization

What is the purpose of the lexer in compiler design?
a) Generating intermediate code
b) Converting source code into tokens
c) Translating source code into machine code
d) Optimizing code

Correct Answer: b) Converting source code into tokens

Which of the following is not a part of the semantic analysis phase?
a) Type Checking
b) Symbol Table Management
c) Syntax Checking
d) Intermediate Code Generation

Correct Answer: c) Syntax Checking

Which phase of the compiler detects and reports errors in the source code?
a) Lexical Analysis
b) Syntax Analysis
c) Semantic Analysis
d) Error Handling

Correct Answer: d) Error Handling

Which of the following is not a part of the code generation phase?
a) Register Allocation
b) Instruction Selection
c) Syntax Analysis
d) Peephole Optimization

Correct Answer: c) Syntax Analysis

Which of the following is not a part of the lexical analysis phase?
a) Removing white spaces
b) Identifying keywords
c) Identifying literals
d) Parsing the source code

Correct Answer: d) Parsing the source code

Which of the following is not a part of the syntax analysis phase?
a) Lexical Analysis
b) Syntax Checking
c) Error Handling
d) Semantic Analysis

Correct Answer: d) Semantic Analysis

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button