1. The main functions of the compiler are …?

a) This requires going through the code line by line

b) Machine code conversion with High-Level Language

c) To execute machine code

d) To optimize code for faster execution

Answer: b) Machine code conversion with High-Level Language

2. Phases of a Compiler — ufology

a) Lexical analysis : Parsing: Optimization: Code generation

b) Syntax analysis, Code execution, Optimization code

c) Parsing, debugging, and code generation

d) Answer: Interpreting, Compiling, Executing

Answer: a) Lexical analysis : Parsing: Optimization: Code generation

3. When is a lexical analyzer used in a compiler?

a) To check syntax errors

b) Generating executable machine code by compiling the Code

c) Compilation from Source Code to Tokens

d) For bytecode optimization for intermediates

Answer: c) Compilation from Source Code to Tokens

4. Which of them is not one kind of parsing a subsequent operation

a) Top-down parsing

b) Bottom-up parsing

c) Semantic parsing

d) Predictive parsing

Answer: c) Semantic parsing

5. Syntax Analysis Phase What does the Syntax analysis phase kick out?

a) Abstract Syntax Tree (AST)

b) Tokens

c) Machine code

d) Object code

Answer: a) Abstract Syntax Tree (AST)

6. What type of grammar is common when constructing a compiler?

a) Context-sensitive grammar

b) Context-free grammar

c) Regular grammar

d) Recursive grammar

Answer: b) Context-free grammar

7. Intermediate code ConstructionAnswers for What is Intermediate code in Compiler building?

a) Unoptimized Source code

b) Intermediate representation of source code, which is independent of machine

c) Object code after linking

d) Compiled Assembly code

Answer: b) Intermediate representation of source code, which is independent of machine

8. The data structure used to implement symbol tables, which is maintained by the compiler.

a) Stack

b) Linked list

c) Hash table

d) Queue

Answer: c) Hash table

9. Semantics related errors can be detected at _________a) Tokenizing phase b) During parsing phase c) Can Errors of this variety be ever caught d) Symbol table creation pointView Answer

a) Syntactic errors

b) Logical errors

c) Type mismatches

d) Lexical errors

Answer: c) Type mismatches

10. In a compiler, the optimization is?????

a) To reduce compilation time

b)Machine Language Compiling. reader(‘=Language_README’);

c) Improved **Generated Code Performance**

d) Remove all syntax bugs

Answer: c) Improved **Generated Code Performance**

11. Which parsing keeps track of intermediate results using a stack?

a) Recursive descent parsing

b) Shift-reduce parsing

c) Predictive parsing

d) LL(1) parsing

Answer: b) Shift-reduce parsing

12. Code Generation (in Compiler)

a) Implement and

b) Secure high-level code

c) To parse the source code

d) To create symbol tables

Answer: b) Secure high-level code

13. Which one is a bottom-up parsing technique?

a) Recursive descent parsing

b) Shift-reduce parsing

c) LL(1) parsing

d) Backtracking parsing

Answer: b) Shift-reduce parsing

14. In a compiler, where will the information about variables, and functions be stored?

a) Abstract Syntax Tree (AST)

b) Intermediate Code Generator

c) Symbol table

d) Code optimizer

Answer: c) Symbol table

15. In which phase the compiler removes the comments and white spaces from the source code?

a) Lexical analysis

b) Syntax analysis

c) Semantic analysis

d) Code generation

Answer: a) Lexical analysis

16. Simple Answer: What type of grammar does LL(1) parser use?

a) Ambiguous grammar

b) Regular grammar

c) Context-free grammar

d) Recursive grammar

Answer: c) Context-free grammar

17. Which of the Implement following is non-deterministic parsing?

a) LL(1) parsing

b) Recursive descent parsing

c) Backtracking parsing

d) Predictive parsing

Answer:c) Backtracking parsing

18. AST (Abstract Syntax Tree): 1.00

a) tree that represents the structure of the source code

b) A table with by variable stored

c) A sequence of tokens

d) A stack used for parsing

Answer: a) tree that represents the structure of the source code

19. Advantages of type checking in the semantic analysis phase

a) To check syntax errors

b) and make use of variables and expressions consistently.

c) For Generation of intermediate code

d) To optimize machine code

Answer: b) and make use of variables and expressions consistently.

20. The Type of Intermediate code:-

a) Binary code

b) Quadruples

c) Machine code

d) Tokens

Answer: b) Quadruples

21. What does a linker do?

a) Translation of low-level code to high-level(OpCodes).

b) To aggregate object code into one executable

c) To check for syntax errors

d) For the lexical analysis

Answer: b) To aggregate object code into one executable

22. What are left to right parsing with a rightmost derivation?

a) LL(1) parsing

b) Recursive descent parsing

c) LR parsing

d) Top-down parsing

Answer: c) LR parsing

23 . What type of error is generally caught at the lexical analysis stage?

a) Type mismatch

b) Division by zero

c) Invalid token

d) Undefined variable

Answer: c) Invalid token

24. WHY SEMANTIC ANALYSIS?

a) To generate machine code

and b) Create efficient code.

c) To ensure the program is logically correct

d) Remove unnecessary tokens

Answer: c) To ensure that the program is logically correct

25. Which of the following is an intermediate or high-level compiler phase that does machine-independent optimization?

a) Lexical analysis

b) Semantic analysis

c) Optimization of intermediate code

d) Code generation

Answer: c) Optimization of intermediate code

26. What is the main advantage of using Intermediate Code in Compilers?

a) Lesser Syntax Errors

b) Machine-independent optimization is possible with it.

c) Faster down the final program.

d) It eases on code generation

Answer: b) Machine-independent optimization is possible with it.

27. What does ‘shift’ mean in LR parsing?

a) Pop the next token from the input, and push it onto the stack

b) A behind-the-scenes way to collapse the stack down to a single value

c) To skip over an error

d) For right-left input parsing.

Answer: a) Pop the next token from the input, and push it onto the stack

28. Which of the following is not a phase in the compiler?

a) Syntactic analysis

b) Code optimization

c) Memory management

d) Lexical analysis

Answer: c) Memory management

29. What does a code optimizer do?

a) To parse the source code

b) To enhance the quality of the code that is generated

c) To link object files

d) Converting high-level code to machine code

Answer: b) To enhance the quality of the code that is generated

30. What are LL(1) parsing techniques

a) Top-down parsing

b) Bottom-up parsing

c) Shift-reduce parsing

d) Recursive descent parsing

Answer: a) Top-down parsing

31. Code Generation in Compiler Design

a) Tokenising to Trees of Tokens

b) Intermediate code to machine code conversion

( C ) Converting source code into object code

d) Type of evaluations or variables

Answer: b) Intermediate code-to-machine code conversion

32. Which of the following would best describe a syntax-directed translation?

a) Tree-to-tree-based translation

b) Semantic rules-only Translation

c) Lexical Tokens Translation

d) Direct translation without intermediary steps a for i b) Flat translations with no games on production centers c) Plain translating, there is no playing in the major domain

Answer: a) Tree to tree-based translation

33. Backpatching in Compiler Design

a) the process by which machine code is generated

b) The process of updating destination addresses (for branch instructions)

c) Type-checking process while doing semantic analysis.

d) Machine code.optimization process

Answer: b) The process of updating destination addresses (for branch instructions)

34. What is the role of an LR parser in a compiler?

a) For scanning the input from right to left.

b) To create machine code

c) To detect lexical errors

d) Parsing context-free grammars efficiently

Answer: d) Parsing context-free grammars efficiently

35. Which one of these is not an optimization from the list below that eliminates dead code?

a) Loop unrolling

b) Dead code elimination

c) Constant folding

d) Strength reduction

Answer:b) Dead code elimination

36. Create a parse tree in which phase of a compiler?

a) Lexical analysis

b) Syntax analysis

c) Semantic analysis

d) Code generation

Answer: b) Syntax analysis

37. Which of the following features does a good compiler NOT have?

a) High efficiency

b) Long compilation time

c) Accurate error reporting

d) Fast code generation

Answer: b) Long compilation time

38. What kinds of errors does the compiler check for at this stage in semantic analysis?

a) Memory allocation errors

b) Logical errors

c) Type compatibility errors

d) Invalid token errors

Answer: c) Type compatibility errors

39. Describe what an intermediate code generator does in a compiler.

a) To parse the source code

b) For creating machine-independent code.

c) To validate the type of consistency

d) To combine many object files.

Answer: b) For creating machine-independent code.

40. Which parsing method would you be faster in most cases?

a) Top-down parsing

b) Bottom-up parsing

c) Recursive descent parsing

d) LL(1) parsing

Answer: b) Bottom-up parsing

Scroll to Top