wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

UNIT - 1 A Compiler Concepts Quiz

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.

What is the primary purpose of a compiler?

a)

To execute a program directly

b)

To translate source code into machine code

c)

To debug a program

d)

To edit source code

2.

Which of the following is a key difference between a compiler and an interpreter?

a)

Compilers execute code line by line

b)

Interpreters convert entire code into machine language at once

c)

Compilers require preprocessing, interpreters do not

d)

Compilers translate the entire program before execution

3.

Which programming language typically uses a compiler?

a)

Python

b)

JavaScript

c)

C++

d)

PHP

4.

What is the main role of an interpreter?

a)

To optimize machine code

b)

To execute high-level code line by line

c)

To generate intermediate code

d)

To debug syntax errors

5.

Which of these programming languages commonly uses an interpreter?

a)

Java

b)

Python

c)

C++

d)

C

6.

Why are interpreters slower than compilers?

a)

Because they generate optimized code

b)

Because they translate and execute code simultaneously

c)

Because they require more memory

d)

Because they use intermediate languages

7.

What is the first step in the analysis of a source program?

a)

Syntax analysis

b)

Semantic analysis

c)

Lexical analysis

d)

Code generation

8.

What does lexical analysis produce?

a)

Syntax tree

b)

Token stream

c)

Intermediate code

d)

Error messages

9.

Which phase checks whether the source program adheres to the rules of the language?

a)

Semantic analysis

b)

Syntax analysis

c)

Lexical analysis

d)

Code optimization

10.

Semantic analysis ensures which of the following?

a)

Syntax rules are followed

b)

Tokens are identified

c)

Meaning of statements is correct

d)

Machine code is optimized

11.

Which of the following is NOT a cousin of the compiler?

a)

Assembler

b)

Loader

c)

Debugger

d)

Optimizer

12.

What does an assembler do?

a)

Converts high-level code into assembly code

b)

Converts assembly language into machine code

c)

Executes assembly programs

d)

Optimizes machine code

13.

Which tool is responsible for loading an executable program into memory?

a)

Compiler

b)

Assembler

c)

Loader

d)

Debugger

14.

Which cousin of the compiler is used to identify and remove errors in the program?

a)

Interpreter

b)

Debugger

c)

Preprocessor

d)

Linker

15.

What are the two main groups of compiler phases?

a)

Analysis and synthesis

b)

Front-end and back-end

c)

Lexical and semantic

d)

Optimization and generation

16.

Which of the following belongs to the synthesis phase?

a)

Lexical analysis

b)

Syntax analysis

c)

Code generation

d)

Semantic analysis

17.

The front-end of a compiler deals with:

a)

Machine code generation

b)

Source program analysis

c)

Code optimization

d)

Linking and loading

18.

The back-end of a compiler is responsible for:

a)

Code optimization and code generation

b)

Syntax and semantic analysis

c)

Tokenization

d)

Lexical analysis

19.

Which phase of the compiler generates a parse tree?

a)

Code generation

b)

Syntax analysis

c)

Lexical analysis

d)

Semantic analysis

20.

Which of the following is a primary function of code optimization?

a)

Generate tokens

b)

Improve performance and reduce size

c)

Ensure syntactic correctness

d)

Translate code to machine language

21.

What is the role of intermediate code generation in a compiler?

a)

To execute the source program directly

b)

To generate human-readable code

c)

To create a platform-independent code representation

d)

To identify syntax errors

22.

Which of the following tools checks for syntax errors during the compilation process?

a)

Debugger

b)

Lexer

c)

Parser

d)

Optimizer

23.

Which phase of the compiler converts intermediate code into machine code?

a)

Code optimization

b)

Code generation

c)

Syntax analysis

d)

Semantic analysis

24.

What is the output of the lexical analysis phase?

a)

Syntax tree

b)

Symbol table

c)

Tokens

d)

Intermediate code

25.

In which phase are type mismatches typically detected?

a)

Lexical analysis

b)

Syntax analysis

c)

Semantic analysis

d)

Code generation