Compiler Design MCQ Questions And Answers

11. Which tool is used for grouping of characters in tokens in the compiler?

  1. Parser
  2. Code generator
  3. Scanner
  4. Code optimizer

Answer : C
Explanation: Scanner is used for grouping of characters in tokens in the compiler. Scanner is a subroutine which is called by the compiler program and it combines the characters and implements them to produce tokens. So, option C is correct.

12. A set of instructions executed directly by a computer’s central processing unit is

  1. Command Language
  2. Machine Language
  3. Style Sheet Language
  4. Markup Language

Answer : B
Explanation: A set of instructions executed directly by a computer’s central processing unit is machine language.

13. The method which merges the bodies of two loops is

  1. Loop unrolling
  2. Constant folding
  3. Loop jamming
  4. None of the above

Answer : C
Explanation: The method which merges the bodies of two loop is loop jamming.

14.  Which of the following actions an operator precedence parser may take to recover from an error?

  1. Delete symbols from the stack
  2. Inserting or deleting symbols from the input
  3. Insert symbols onto the stack
  4. All of the above

Answer : D
Explanation: The actions an operator precedence parser may take to recover from an error are: Delete symbols from the stack, Inserting or deleting symbols from the input and Insert symbols onto the stack, so all of the above option is correct.

15. What is the output of the lexical analyzer?

  1. A parse tree
  2. A list of tokens
  3. Machine code
  4. Intermediate code

Answer : B
Explanation: The output of lexical analyzer is a list of tokens.

Computer Networks MCQ Questions And Answers

16. When is the type checking usually done?

  1. During syntax directed translation
  2. During syntax analysis
  3. During lexical analysis
  4. During code optimization

Answer : A
Explanation: The type checking usually done during syntax directed translation.

17. A grammar that produces more than one parse tree for some sentence is called as

  1. Unambiguous
  2. Ambiguous
  3. Regular
  4. None of the above

Answer : B
Explanation: A grammar that produces more than one parse tree for some sentence is called as ambiguous grammar.

18. Lexical analysis is about breaking a sequence of characters into

  1. Packets
  2. Lines
  3. Tokens
  4. Groups

Answer : C
Explanation: Lexical analysis is about breaking a sequence of characters into tokens.

19. What is the use of a symbol table in compiler design?

  1. Finding name’s scope
  2. Type checking
  3. Keeping all of the names of all entities in one place
  4. All of the above

Answer : D
Explanation: The use of a symbol table in compiler design are: Finding name’s scope, Type checking, Keeping all of the names of all entities in one place. So, all of the above option is correct.

20. Identify the data structure which has minimum access time in case of symbol table implementation?

  1. Hash table
  2. Self-organizing list
  3. Linear
  4. Search tree

Answer : A
Explanation: The access time of hash table is O(1) which makes it the most efficient data structure in the case of symbol table implementation.

Leave a Reply