Compiler Design Questions and Answers - Lexical Analyser Part-1

1. What is another name for Lexical Analyser?
a) Linear Phase
b) Linear Analysis
c) Scanning
d) All of the mentioned

Answer: d
Explanation: Lexical Analyzer is also called “Linear Phase” or “Linear Analysis” or “Scanning“.

2. An individual token is called ________
a) Lexeme
b) Lex
c) Lexeme & Lex
d) None of the mentioned

Answer: a
Explanation: Individual Token is also Called Lexeme.

3. Lexical Analyser’s Output is given to Syntax Analysis.
a) True
b) False

Answer: a
Explanation: Lexical Analyzer’s Output is given to Syntax Analysis.

4. Which phase of the compiler is Lexical Analyser?
a) First
b) Second
c) Third
d) None of the mentioned

Answer: a
Explanation: Lexical Analyzer is First Phase of Compiler.

5. Input to Lexical Analyser is _________
a) Source Code
b) Object Code
c) Lexeme
d) None of the mentioned

Answer: a
Explanation: Lexical analyser’s Input is Source Code.

6. Lexical Analysis Identifies Different Lexical Units in a _______
a) Source Code
b) Object Code
c) Lexeme
d) None of the mentioned

Answer: a
Explanation: Lexical Analysis Identifies Different Lexical Units in a source Code.

7. Which one is a type of Lexeme?
a) Identifiers
b) Constants
c) Keywords
d) All of the mentioned

Answer: d
Explanation: All of them along with Operators are different types of lexemes.

8. A ________ is a string of characters which form a syntactic unit.
a) Lexeme
b) Lex
c) Lexeme & Lex
d) None of the mentioned

Answer: a
Explanation: A lexeme is a string of characters that form a syntactic unit.

9. The process of forming tokens from an input stream of characters is called __________
a) Liberalisation
b) Characterisation
c) Tokenization
d) None of the mentioned

Answer: c
Explanation: The process of forming tokens from an input stream of characters is called tokenization.

10. When expression sum=3+2 is tokenized then what is the token category of 3?
a) Identifier
b) Assignment operator
c) Integer Literal
d) Addition Operator

Answer: c
Explanation: Integer Literal