Q. What does the term 'symbol table' refer to in a compiler?
A.
A table of syntax rules
B.
A data structure that stores information about identifiers
C.
A list of optimization techniques
D.
A representation of the abstract syntax tree
Show solution
Solution
A symbol table is a data structure that stores information about identifiers, such as their types and scopes.
Correct Answer:
B
— A data structure that stores information about identifiers
Learn More →
Q. What is intermediate code in the context of compilers?
A.
The final machine code
B.
A high-level representation of the source code
C.
An abstract representation of the program
D.
The source code itself
Show solution
Solution
Intermediate code is an abstract representation of the program that is independent of the target machine, allowing for easier optimization and code generation.
Correct Answer:
C
— An abstract representation of the program
Learn More →
Q. What is the main function of the runtime environment in a programming language?
A.
To compile the source code
B.
To manage memory and resources during execution
C.
To perform lexical analysis
D.
To generate intermediate code
Show solution
Solution
The runtime environment manages memory, handles input/output, and provides other services needed during the execution of a program.
Correct Answer:
B
— To manage memory and resources during execution
Learn More →
Q. What is the primary function of a lexical analyzer in a compiler?
A.
To generate intermediate code
B.
To parse the source code
C.
To tokenize the input source code
D.
To optimize the code
Show solution
Solution
The lexical analyzer's primary function is to tokenize the input source code, breaking it down into meaningful symbols.
Correct Answer:
C
— To tokenize the input source code
Learn More →
Q. What is the primary purpose of lexical analysis in a compiler?
A.
To generate intermediate code
B.
To convert source code into tokens
C.
To optimize the code
D.
To perform syntax checking
Show solution
Solution
Lexical analysis converts the source code into tokens, which are the basic building blocks for further processing in the compiler.
Correct Answer:
B
— To convert source code into tokens
Learn More →
Q. What is the purpose of code generation in a compiler?
A.
To analyze the syntax of the source code
B.
To produce machine code from intermediate code
C.
To optimize the source code
D.
To perform lexical analysis
Show solution
Solution
Code generation is the phase where the compiler translates intermediate code into machine code that can be executed by the target machine.
Correct Answer:
B
— To produce machine code from intermediate code
Learn More →
Q. What is the purpose of type checking in a compiler?
A.
To ensure that the program runs faster
B.
To verify that operations are performed on compatible data types
C.
To optimize the code
D.
To generate intermediate code
Show solution
Solution
Type checking verifies that operations are performed on compatible data types, ensuring program correctness.
Correct Answer:
B
— To verify that operations are performed on compatible data types
Learn More →
Q. What is the role of a symbol table in a compiler?
A.
To store the intermediate code
B.
To keep track of variable names and their attributes
C.
To optimize the code
D.
To perform lexical analysis
Show solution
Solution
The symbol table is used to store information about variable names, types, scopes, and other attributes during the compilation process.
Correct Answer:
B
— To keep track of variable names and their attributes
Learn More →
Q. Which of the following is a characteristic of a runtime environment?
A.
It is only used during compilation
B.
It manages memory allocation and deallocation
C.
It translates high-level code to machine code
D.
It performs syntax analysis
Show solution
Solution
A runtime environment manages memory allocation and deallocation during the execution of a program.
Correct Answer:
B
— It manages memory allocation and deallocation
Learn More →
Q. Which of the following is a common data structure used to represent the syntax tree in compilers?
A.
Array
B.
Linked list
C.
Binary tree
D.
Hash table
Show solution
Solution
A binary tree is commonly used to represent the syntax tree, where each node represents a construct in the source code.
Correct Answer:
C
— Binary tree
Learn More →
Q. Which of the following is NOT a phase of syntax analysis?
A.
Parsing
B.
Lexical analysis
C.
Semantic analysis
D.
Intermediate code generation
Show solution
Solution
Intermediate code generation is not a phase of syntax analysis; it occurs after syntax analysis.
Correct Answer:
D
— Intermediate code generation
Learn More →
Q. Which of the following is NOT a phase of the compilation process?
A.
Lexical analysis
B.
Syntax analysis
C.
Runtime environment setup
D.
Code generation
Show solution
Solution
Runtime environment setup is not a phase of compilation; it is part of the execution of the compiled program.
Correct Answer:
C
— Runtime environment setup
Learn More →
Showing 1 to 12 of 12 (1 Pages)