Compiler Design

Download Q&A
Q. Which of the following best describes 'tokenization'?
  • A. The process of generating machine code
  • B. The process of converting source code into tokens
  • C. The process of optimizing code
  • D. The process of parsing syntax
Q. Which of the following best describes inherited attributes?
  • A. Attributes passed from parent to child nodes
  • B. Attributes computed from child nodes
  • C. Attributes that do not affect the translation
  • D. Attributes that are only used in semantic actions
Q. Which of the following best describes synthesized attributes?
  • A. Attributes that are passed down from parent to child nodes
  • B. Attributes that are computed from the values of child nodes
  • C. Attributes that are used only during lexical analysis
  • D. Attributes that are not used in syntax-directed translation
Q. Which of the following best describes the relationship between a lexer and a parser?
  • A. The lexer generates machine code, while the parser checks syntax
  • B. The lexer produces tokens, which the parser uses to build a syntax tree
  • C. The lexer and parser perform the same function
  • D. The parser generates tokens, while the lexer checks syntax
Q. Which of the following best describes the relationship between syntax trees and intermediate code?
  • A. Syntax trees are generated after intermediate code
  • B. Intermediate code is generated directly from syntax trees
  • C. Syntax trees and intermediate code are the same
  • D. Intermediate code is generated before syntax trees
Q. Which of the following grammars can be parsed using LL(1) parsing?
  • A. Left-recursive grammars
  • B. Ambiguous grammars
  • C. Non-left-recursive and unambiguous grammars
  • D. Context-free grammars only
Q. Which of the following is a benefit of using intermediate code in a compiler?
  • A. It eliminates the need for parsing
  • B. It allows for easier debugging of the source code
  • C. It enables code generation for multiple target architectures
  • D. It simplifies lexical analysis
Q. Which of the following is a characteristic of a runtime environment?
  • A. It is only used during compilation
  • B. It manages memory allocation and deallocation
  • C. It translates high-level code to machine code
  • D. It performs syntax analysis
Q. Which of the following is a characteristic of LL(1) parsing?
  • A. It uses a stack for parsing
  • B. It can handle left recursion
  • C. It requires backtracking
  • D. It is a top-down parsing method
Q. Which of the following is a common data structure used to represent the syntax tree in compilers?
  • A. Array
  • B. Linked list
  • C. Binary tree
  • D. Hash table
Q. Which of the following is a common error detected by a lexical analyzer?
  • A. Syntax errors
  • B. Type errors
  • C. Unrecognized characters
  • D. Semantic errors
Q. Which of the following is a common form of intermediate code generated by syntax-directed translation?
  • A. Assembly language
  • B. Three-address code
  • C. Bytecode
  • D. Machine code
Q. Which of the following is a common method for performing constant folding?
  • A. Evaluating expressions at compile time
  • B. Removing unused variables
  • C. Inlining functions
  • D. Rearranging code for efficiency
Q. Which of the following is a common technique used in code optimization?
  • A. Inlining functions
  • B. Adding more comments
  • C. Increasing variable scope
  • D. Using more complex data structures
Q. Which of the following is a common technique used in lexical analysis?
  • A. Recursive descent parsing
  • B. Finite state machines
  • C. Dynamic programming
  • D. Backtracking
Q. Which of the following is a key advantage of LR parsing over LL parsing?
  • A. LR parsing can handle left recursion.
  • B. LR parsing is simpler to implement.
  • C. LL parsing can handle more complex grammars.
  • D. LR parsing requires less memory.
Q. Which of the following is a requirement for an LL(1) parser?
  • A. The grammar must be left recursive.
  • B. The grammar must be ambiguous.
  • C. The grammar must be free of left recursion.
  • D. The grammar must have multiple left factors.
Q. Which of the following is an advantage of using intermediate code?
  • A. It simplifies the parsing process
  • B. It allows for easier debugging
  • C. It enables machine-independent optimizations
  • D. It eliminates the need for a front-end
Q. Which of the following is an example of a syntax error?
  • A. Using an undeclared variable
  • B. Missing a semicolon
  • C. Dividing by zero
  • D. Using the wrong data type
Q. Which of the following is NOT a benefit of code optimization?
  • A. Improved performance
  • B. Reduced memory usage
  • C. Increased code complexity
  • D. Faster execution time
Q. Which of the following is NOT a common form of intermediate code?
  • A. Three-address code
  • B. Abstract syntax tree
  • C. Bytecode
  • D. Machine code
Q. Which of the following is NOT a phase of syntax analysis?
  • A. Parsing
  • B. Lexical analysis
  • C. Semantic analysis
  • D. Intermediate code generation
Q. Which of the following is NOT a phase of the compilation process?
  • A. Lexical analysis
  • B. Syntax analysis
  • C. Runtime environment setup
  • D. Code generation
Q. Which of the following is NOT a type of attribute in syntax-directed translation?
  • A. Synthesized attribute
  • B. Inherited attribute
  • C. Static attribute
  • D. Contextual attribute
Q. Which of the following is NOT a type of LR parser?
  • A. SLR
  • B. LALR
  • C. LR(1)
  • D. LL(1)
Q. Which of the following is NOT a type of parsing technique?
  • A. Top-down parsing
  • B. Bottom-up parsing
  • C. Left-to-right parsing
  • D. Right-to-left parsing
Q. Which of the following is NOT a typical output of a lexical analyzer?
  • A. Tokens
  • B. Symbol table
  • C. Abstract syntax tree
  • D. Error messages
Q. Which of the following is true about SLR parsing?
  • A. It uses a single lookahead token.
  • B. It is a type of LL parsing.
  • C. It can handle all context-free grammars.
  • D. It is less powerful than canonical LR parsing.
Q. Which of the following optimizations can be performed on intermediate code?
  • A. Dead code elimination
  • B. Lexical analysis
  • C. Syntax checking
  • D. Code generation
Q. Which of the following parsing techniques can handle a larger class of grammars?
  • A. LL parsing
  • B. LR parsing
  • C. Recursive descent parsing
  • D. Predictive parsing
Showing 61 to 90 of 98 (4 Pages)
Soulshift Feedback ×

On a scale of 0–10, how likely are you to recommend The Soulshift Academy?

Not likely Very likely