250+ TOP MCQs on Lexical Analysis and Answers

Compilers Multiple Choice Questions & Answers (MCQs) on “Lexical Analysis”.

1. What is the output of lexical analyzer?
a) A set of RE
b) Syntax Tree
c) Set of Tokens
d) String Character

Answer: c
Clarification: A lexical analyzer coverts character sequences to set of tokens.

2. Which symbol table implementation is based on the property of locality of reference?
a) Linear list
b) Search tree
c) Hash Table
d) Self Organisation

Answer: c
Clarification: Hash table is used as a reference for symbol table because it is efficient.

3. Which of the following is true for operator precedence parsing?
a) For all pair of non-terminal
b) For all pair of non-terminals
c) To delimit the handle
d) None of the mentioned

Answer: a
Clarification: There are two important properties for these operator precedence parsers is that it does not appear on the right side of any production and no production has two adjacent non-terminals. Implying that no production right side is empty or has two adjacent non-terminals. So accordingly to property option (A) is correct.

4. 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

Answer: c
Clarification: Since the input is the source language and the output that we get after the analysis is the machine language.

5. Which concept of FSA is used in the compiler?
a) Lexical analysis
b) Parser
c) Code generation
d) Code optimization

Answer: a
Clarification: Because the lexer performs its analysis by going from one stage to another.

6. Which concept of grammar is used in the compiler?
a) Lexical analysis
b) Parser
c) Code generation
d) Code optimization

Answer: b
Clarification: As the lexical analysis of a grammar takes place in phases hence it is synonymous to parser.

7. Which of the following are Lexemes?
a) Identifiers
b) Constants
c) Keywords
d) All of the mentioned

Answer: d
Clarification: Different Lexical Classes or Tokens or Lexemes Identifiers, Constants, Keywords, Operators.

Leave a Reply

Your email address will not be published.