Compilers Questions and Answers – Lexical Analyser – 1

This set of Compilers Multiple Choice Questions & Answers (MCQs) focuses on “Lexical Analyser – 1”.

1. In a compiler the module that checks every character of the source text is called __________
a) The code generator
b) The code optimizer
c) The lexical analyzer
d) The syntax analyzer
View Answer

Answer: c
Explanation: Lexical analyser is the process of converting a sequence of characters into a sequence of tokens.

2. The context free grammar is ambiguous if ______________
a) The grammar contains non-terminals
b) Produces more than one parse tree
c) Production has two non-terminals side by side
d) None of the mentioned
View Answer

Answer: b
Explanation: Since more than one parse tree is generated hence one than option is available .Therefore it’s ambiguous.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Sanfoundry Global Education & Learning Series – Compilers.

To practice all areas of Compilers, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.