About Compiler Design

Following are some of the multiple choice questions on the Compiler Design with answers that will help the students in developing their knowledge.

Compiler Design MCQ

1. DAG means

  • Directed Acyclic Graph
  • Deterministic Acyclic graph
  • Directed Automated Graph
  • Deterministic Automated graph

2. What is the output of lexical analyzer?

  • A parse tree
  • A list of tokens
  • Intermediate code
  • Machine code

3. LR stands for

  • left to right scanning
  • left to right reduction
  • leftmost to rightmost derivation
  • left to right scanning and right most derivation in reverse

4. What is machine code?

  • Instructions and data in binary
  • Serial number of the CPU
  • Instructions and data in human readable form
  • Instructions and data in assembly code mnemonics

5. Which one of the following statements is FALSE ?

  • Context-free grammar can be used to specify both lexical and syntax rules.
  • Type checking is done before parsing.
  • High-level language programs can be translated to different Intermediate Representations.
  • Both A & B

6. One of the purposes of using intermediate code in compilers is to

  • make parsing and semantic analysis simpler
  • improve error recovery and error reporting
  • improve the register allocation
  • increase the chances of reusing the machine-independent code optimizer in other compilers

7. Which one of the following is FALSE?

  • A basic block is a sequence of instructions where control enters the sequence at the beginning and exits at the end
  • Available expression analysis can be used for common subexpression elimination
  • Live variable analysis can be used for dead code elimination
  • x = 4 ∗ 5 => x = 20 is an example of common subexpression elimination

8. Some code optimizations are carried out on the intermediate code because

  • the information from the front end cannot otherwise be used for optimization
  • program analysis is more accurate on intermediate code than on machine code
  • the information from dataflow analysis cannot otherwise be used for optimization
  • they enhance the portability of the compiler to other target processors

9. An optimizing Compiler?

  • Is optimized to occupy less space
  • Optimizes the code
  • Is optimized to take less time for execution
  • All of above

10. Consider the regular expression 0 * (10 *) which is similar to the same set as

  • 0 + (0 + 10) *
  • (0 +1) * 10 (0 + 1) *
  • (1 * 0) * 1*
  • None of the above

11. A grammar for a programming language is a formal description of

  • Structure
  • Syntax
  • Semantics
  • Code

12. Consider the following simple context-free grammar: S → Aa ⁄ bAc ⁄ dc ⁄ bda Determine true (T), false (F) of the following statements: i) The grammar is SLR (1) ii) The grammar is LR (1) iii) The grammar is LALR (1)?

  • (i) – T (ii) – T (iii) – T
  • (i) – F (ii) – T (iii) – T
  • (i) – T (ii) – F (iii) – T
  • None of these

13. Syntax directed translation scheme is desirable because

  • it is based on the syntax
  • its description is independent of any implementation
  • it is easy to modify
  • all of these

14. The flow of control in a program of activation tree can be represented by

  • Depth-first traversal
  • B-tree
  • Breadth-first traversal
  • Both A & B

15. What does a Syntactic Analyser do?

  • Maintain Symbol Table
  • Create parse tree
  • Collect type of information
  • None of the mentioned

16. Which of these is not a stage in the compilation process:


17. A compiler is a

  • Translator
  • System Software
  • Above 2
  • Inerpreter

18. Removal of left recursion is necessary because?

  • It causes recursive decent parser to loop forever
  • It generates an ambiguous grammar
  • Both a and b
  • None of these

19. The role of predictive parsing is

  • To construct a top-down parser that never backtracks
  • To construct a top-down parser that backtracks
  • To construct a bottom-up parser that never backtracks
  • All of above

20. In context to the process of removing useless symbols, which of the following is correct?

  • We remove the Nullable variables
  • We eliminate the unit productions
  • We eliminate products which yield no terminals/strings
  • All of the mentioned

21. A system program that set-up an executable program in main memory ready for execution is

  • loader
  • linker
  • assembler
  • None of the above

22. Compilers, assemblers and interpreters are examples of this.

  • Translator
  • Run time environment
  • Editor
  • Error diagnostics

23. A basic block can be analyzed by?

  • Flowgraph
  • A graph with cycles
  • DAG
  • Both A & B

24. Which of the following system software resides in the main memory always

  • Text Editor
  • Assembler
  • Linker
  • Loader

25. Type checking is normally done during?

  • Lexical Analysis
  • Syntax Analysis
  • Syntax Directed Translation
  • Code generation

26. Consider the following grammar. Which of the following is true regarding LL (1) grammar?

  • No ambiguous or left recursive grammar can be LL(1)
  • No ambiguous but left recursive grammar can be LL(1)
  • No left recursive but ambiguous grammar can be LL(1)
  • All of above

27. Replacement of an expensive operation by a cheaper one is termed as?

  • Reduction in strength
  • Code motion
  • Loop invariant computation
  • All of above

28. The output of a lexical analyzer is

  • A parse tree
  • Intermediate code
  • Machine code
  • A stream of tokens

29. Access time is minimum for accessing the symbol table which uses?

  • Hash table
  • Search tree
  • Self-organizing list
  • All of above

30. What is the problem writing machine code?

  • Quick to learn
  • Easy to debug
  • Easy to read
  • Hard to remember the binary codes Hard to remember the binary codes

31. In a syntax directed translation scheme, if value of an attribute of a node is a function of the values of the attributes of its children, then it is called

  • synthesized attribute
  • inherited attribute
  • canonical attribute
  • None of the above

32. Compilers translate high-level language into machine code.

  • True
  • False

33. A parse tree showing the value of attributes at each node

  • syntax tree
  • annotated parse tree
  • semantic tree
  • all of the above

34. Consider the following grammar: A → cAd A → ab/ac/a For Input string cad, how many times the recursive descent parser will backtrack ?

  • 2
  • 3
  • 4
  • None of these

35. Number of states require to accept string ends with 10.

  • 3
  • 2
  • 1
  • can’t be represented.

36. Given: ∑= {a, b}L= {xϵ∑*|x is a string combination} ∑4 represents which among the following?

  • {aa, ab, ba, bb}
  • {aaaa, abab, ε, abaa, aabb}
  • {aaa, aab, aba, bbb}
  • All of the above

37. It is known as the front-end of the compiler.

  • Analysis Phase
  • Synthesis

38. The lexical analysis for a modern computer language such as Java needs the power of which one of the following machine models in a necessary and sufficient sense?

  • Finite state automata
  • Deterministic pushdown automata
  • Non-Deterministic pushdown automata
  • All of above

39. Which of the following parsers is the most powerful?

  • SLR(1)
  • CLR(1)
  • LALR(1)
  • Operator Precedence

40. For DAG interior nodes represents

  • Names
  • Identifiers
  • Constants
  • Operator

41. A parse tree showing attribute value at each node is called?

  • Concrete tree
  • Syntax tree
  • Annotated parse tree
  • All of above

42. Local and loop optimization in turn provides motivation for?

  • Data flow Analysis
  • Peephole optimization
  • DRA and constant folding
  • All of above

43. Inherited attribute is a natural choice in

  • keeping track of variable declaration
  • checking for the correct use of L-values and R-values
  • both (a) and (b)
  • None of these

44. Output file of Lex is _____ the input file is Myfile?

  • Myfile.e
  • Myfile.yy.c
  • Myfile.lex
  • Myfile.obj

45. In SLR parsing for the grammar E’-->E , E--> aEbE|bEaE|ε, In state 0, for inputs ‘a’ and ‘b’

  • Both will have shift-reduce conflict
  • Only ‘a’ will have shift-reduce conflict
  • Only ‘b’ will have shift-reduce conflict
  • Neither of the other option

46. The grammar {E-->E+T|T, T-->T*F|F, F-->id} is

  • Ambiguous
  • Unambiguous
  • Partially ambiguous
  • None of the other options

47. The symbol table implementation is based on the property of locality of reference is -

  • Hash Table
  • Self Organisation
  • Linear list
  • None of the above

48. For a context-free grammar, left hand side of production rules should contain

  • Single nonterminal
  • Set of both terminals and nonterminals
  • Set of terminals
  • None of the other options

49. The regular expression (0|1)*(0|1) represents a language with

  • Odd nonempty strings
  • Even nonempty strings
  • Empty and nonempty binary strings
  • Nonempty binary strings

50. Directly executable by the CPU. Written in 1's and 0's or Hex.

  • Machine Code
  • High Level Language
  • Assembly Language
  • VB.net

Enjoyed the Quiz. Share this with friends


Add Your Review

Your email address will not be published.

Subscribe to Newsletter!

Subscribe to get latest updates and information.