NEW
Font size
WorksheetsUNIT - 1 A Compiler Concepts Quiz
Total questions: 25
Worksheet time: 13mins
What is the primary purpose of a compiler?
To execute a program directly
To translate source code into machine code
To debug a program
To edit source code
Which of the following is a key difference between a compiler and an interpreter?
Compilers execute code line by line
Interpreters convert entire code into machine language at once
Compilers require preprocessing, interpreters do not
Compilers translate the entire program before execution
Which programming language typically uses a compiler?
Python
JavaScript
C++
PHP
What is the main role of an interpreter?
To optimize machine code
To execute high-level code line by line
To generate intermediate code
To debug syntax errors
Which of these programming languages commonly uses an interpreter?
Java
Python
C++
C
Why are interpreters slower than compilers?
Because they generate optimized code
Because they translate and execute code simultaneously
Because they require more memory
Because they use intermediate languages
What is the first step in the analysis of a source program?
Syntax analysis
Semantic analysis
Lexical analysis
Code generation
What does lexical analysis produce?
Syntax tree
Token stream
Intermediate code
Error messages
Which phase checks whether the source program adheres to the rules of the language?
Semantic analysis
Syntax analysis
Lexical analysis
Code optimization
Semantic analysis ensures which of the following?
Syntax rules are followed
Tokens are identified
Meaning of statements is correct
Machine code is optimized
Which of the following is NOT a cousin of the compiler?
Assembler
Loader
Debugger
Optimizer
What does an assembler do?
Converts high-level code into assembly code
Converts assembly language into machine code
Executes assembly programs
Optimizes machine code
Which tool is responsible for loading an executable program into memory?
Compiler
Assembler
Loader
Debugger
Which cousin of the compiler is used to identify and remove errors in the program?
Interpreter
Debugger
Preprocessor
Linker
What are the two main groups of compiler phases?
Analysis and synthesis
Front-end and back-end
Lexical and semantic
Optimization and generation
Which of the following belongs to the synthesis phase?
Lexical analysis
Syntax analysis
Code generation
Semantic analysis
The front-end of a compiler deals with:
Machine code generation
Source program analysis
Code optimization
Linking and loading
The back-end of a compiler is responsible for:
Code optimization and code generation
Syntax and semantic analysis
Tokenization
Lexical analysis
Which phase of the compiler generates a parse tree?
Code generation
Syntax analysis
Lexical analysis
Semantic analysis
Which of the following is a primary function of code optimization?
Generate tokens
Improve performance and reduce size
Ensure syntactic correctness
Translate code to machine language
What is the role of intermediate code generation in a compiler?
To execute the source program directly
To generate human-readable code
To create a platform-independent code representation
To identify syntax errors
Which of the following tools checks for syntax errors during the compilation process?
Debugger
Lexer
Parser
Optimizer
Which phase of the compiler converts intermediate code into machine code?
Code optimization
Code generation
Syntax analysis
Semantic analysis
What is the output of the lexical analysis phase?
Syntax tree
Symbol table
Tokens
Intermediate code
In which phase are type mismatches typically detected?
Lexical analysis
Syntax analysis
Semantic analysis
Code generation
