0% found this document useful (0 votes)
64 views7 pages

CD Unit 1 MCQ

The document contains multiple-choice questions (MCQs) related to the compilation process, including topics such as lexical analysis, syntax analysis, and the roles of different components of a compiler. It covers definitions, functions, and phases of compilers, along with specific tools and data structures used in the process. The document serves as a study guide for understanding compiler design and implementation.

Uploaded by

vkyashraj20
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views7 pages

CD Unit 1 MCQ

The document contains multiple-choice questions (MCQs) related to the compilation process, including topics such as lexical analysis, syntax analysis, and the roles of different components of a compiler. It covers definitions, functions, and phases of compilers, along with specific tools and data structures used in the process. The document serves as a study guide for understanding compiler design and implementation.

Uploaded by

vkyashraj20
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

UNIT 1

MCQ
1 The output of a lexical analyzer is

(a) Parse tree

(b) Intermediate code

(c) Machine code

(d) A stream of tokens

2 Which of the following are Lexemes?

(a) Identifiers

(b) Constants

(c) Keywords

(d) All of the mentioned

3. What constitutes the stages of the compilation process?


a) Feasibility study, system, design, and testing
b) Implementation and documentation
c) Lexical analysis, syntax, Analysis and code generation
d) None of the mentioned

4.The lexical analyzer takes _________ as input and produces a stream of _______ as output.
a) Source program, tokens
b) Token, source program
c) Either of the two
d) None of the mentioned

5. Parsing is also known as ________


a) Lexical Analysis
b) Syntax Analysis
c) Semantic Analysis
d) Code Generation

6. A compiler program written in a high level language is called ________


a) Source Program
b) Object Program
c) Machine Language Program
d) None of the mentioned

7. A system program that brings together separately compiled modules of a program into a
form language that is suitable for execution.
a) Assembler
b) Linking loader
c) Cross compiler
d) None of the mentioned

8 .What is an Object program?


a) Program written in machine language
b) Program to be translated into machine language
c) Translation of high-level language into machine language
d) None of the mentioned

9. What is a compiler?

a) A hardware device

b) A software program

c) A peripheral device

d) A storage device

10. which of the following is a major data structure used in compilers?

a) Arrays
b) Stacks

c) Trees

d) Linked lists

Answer: c) Trees

11. How many types of compilers are there based on the translation process?

a) One

b) Two

c) Three

d) Four

12. Which part of the compiler translates high-level code into intermediate code?

a) Front-end

b) Back-end

c) Middle-end

d) Preprocessor

Answer: a) Front-end

13. Which part of the compiler generates machine code from the intermediate code?

a) Front-end

b) Back-end

c) Middle-end

d) Postprocessor

Answer: b) Back-end
14. Which phase of the compiler checks the syntax of the source code?

a) Lexical analysis

b) Semantic analysis

c) Syntax analysis

d) Code generation

Answer: c) Syntax analysis

15. What is the purpose of lexical analysis in a compiler?

a) Checking syntax errors

b) Generating machine code

c) Tokenizing the source code

d) Optimizing code

Answer: c) Tokenizing the source code

16. Which tool is used for generating lexical analyzers automatically?

a) Yacc

b) Bison

c) Flex

d) ANTLR

Answer: c) Flex

17. What does LEX stand for?


a) Lexical Extraction

b) Lexical Extension

c) Lexical Analyzer Generator

d) Lexical Expression

Answer: c) Lexical Analyzer Generator

18. Which phase of the compiler handles input buffering?

a) Lexical analysis

b) Syntax analysis

c) Semantic analysis

d) Code generation

Answer: a) Lexical analysis

19. Which data structure is commonly used for implementing symbol tables in compilers?

a) Arrays

b) Linked lists

c) Hash tables

d) Trees

Answer: c) Hash tables

20. Which phase of the compiler checks the meaning of the source code?

a) Lexical analysis

b) Syntax analysis

c) Semantic analysis
d) Code generation

Answer: c) Semantic analysis

21. Which phase of the compiler translates intermediate code into machine code?

a) Lexical analysis

b) Syntax analysis

c) Semantic analysis

d) Code generation

Answer: d) Code generation

22. Which part of the compiler optimizes the generated code for efficiency?

a) Lexical analysis

b) Syntax analysis

c) Semantic analysis

d) Code optimization

Answer: d) Code optimization

23. Which phase of the compiler resolves references to variables and functions?

a) Lexical analysis

b) Syntax analysis

c) Semantic analysis

d) Code generation

Answer: c) Semantic analysis

24. Which phase of the compiler removes unnecessary code and reduces code size?
a) Lexical analysis

b) Syntax analysis

c) Semantic analysis

d) Code optimization

Answer: d) Code optimization

You might also like