
This quiz is designed to test your understanding of fundamental concepts of Compiler Constructions.
This quiz is suitable for BS Computer Science students preparing for exams or anyone looking to strengthen their conceptual foundation in Compiler Constructions.
→ COMPILER CONSTRUCTIONS TOPICS
- Introduction to Compilers: Overview of the compilation process.
- The Phases of Compiler: Detailed study of the different stages of a compiler.
- Cousins of Compiler: Related software like assemblers, loaders, and linkers.
- Grouping of Phases: How compiler phases are organized (e.g., front-end vs. back-end).
- Compiler Construction Tools: Software used to help build compilers.
- Simple One-Pass Compiler: Basic compiler design that processes code in a single pass.
- Syntax Definition and Translation: Defining the structure of a language and how it translates.
- Parsing: The process of analyzing a string of symbols.
- A Translator for Simple Expressions: Practical application of translation techniques.
- Lexical Analysis: Breaking source code into tokens.
- Incorporation of Symbol Table: Managing identifiers and their attributes.
- Abstract Stack Machine: A theoretical machine used for code execution models.
- Synthesis of Techniques: Combining various methods for compiler design.
- Input Buffering: Managing how source code is read efficiently.
- Token Specification and Recognition: Defining and identifying legal tokens.
- Language Specifying Lexical Analyzers: Using formalisms to define lexers.
- Automata: Study of Deterministic (DFA) and Non-Deterministic (NFA) Finite Automata.
- Conversion from Regular Expression to NFA: Turning patterns into state machines.
- Design of Lexical Analyzer Generator: Tools like LEX or FLEX.
- Pattern Matching: Finding specific structures within the code.
- Optimization of DFA-Based Pattern Matchers: Improving the efficiency of state machines.
- Syntax Analysis: The role of parsers in the compiler.
- Context-Free Grammar (CFG): Formal rules for defining language syntax.
- Writing Grammar: Techniques for creating structured language rules.
- Top-Down and Bottom-Up Parsing: The two primary approaches to parsing.
- Operator Precedence Parsing: Handling expressions based on operator priority.
- LR Parsers: Advanced bottom-up parsing techniques.
- Removing Ambiguities in CFG: Solving conflicts in grammar rules.
- Parser Generators: Tools like YACC or Bison.
- Syntax-Directed Definition and Translation: Linking semantic actions to syntax rules.
- Construction of Syntax Trees: Visual representation of the hierarchical structure of code.
- Bottom-Up Evaluation of S-Attributed Definitions: Evaluating attributes during parsing.
- L-Attributed Definition: A specific type of attribute grammar.
- Type Checking and Type Systems: Ensuring operations are performed on compatible data types.
- Specification of Simple Type Checker: Creating rules for type validation.
- Equivalence of Type Expression: Determining if two types are the same.
- Type Conversion: Handling changes between different data types.
- Intermediate Code Generation and Optimization: Producing and refining machine-independent code.










1. What is a compiler?
a) system program that converts instructions to machine language
b) system program that converts machine language to high-level language
c) system program that writes instructions to perform
d) None of the mentioned
View Answer
Answer: a
Explanation: A compiler is a system program that converts instructions in form of code to machine understandable language.
2. Which of the following is a stage of compiler design?
a) Semantic analysis
b) Intermediate code generator
c) Code generator
d) All of the mentioned
View Answer
Answer: d
Explanation: The phases of a compiler are:
1. Lexical analysis
2. Syntax analysis
3. Semantic analysis
4. Intermediate code generator
5. Code optimizer
6. Code generator
3. What is the use of a symbol table in compiler design?
a) Finding name’s scope
b) Type checking
c) Keeping all of the names of all entities in one place
d) All of the mentioned
View Answer
Answer: d
Explanation: Both the analysis and synthesis components of a compiler use the symbol table.
i) To keep all of the names of all entities in one place in a systematic format.
ii) To determine whether or not a variable has been declared.
iii) Type checking is implemented by ensuring that assignments and expressions in source code are semantically accurate.
iv) To figure out what a name’s scope is (scope resolution).
4. Which of the following error can a compiler check?
a) Syntax Error
b) Logical Error
c) Both Logical and Syntax Error
d) Compiler cannot check errors
View Answer
Answer: a
Explanation: Logic flaws can never be checked by a compiler.
5. A programmer, writes a program to multiply two numbers instead of dividing them by mistake, how can this error be detected?
a) Compiler or interpreter
b) Compiler only
c) Interpreter only
d) None of the mentioned
View Answer
Answer: d
Explanation: This is a logical error that can’t be detected by any compiler or interpreter.
6. Who is responsible for the creation of the symbol table?
a) Assembler
b) Compiler
c) Interpreter
d) All of the mentioned
View Answer
Answer: b
Explanation: The compiler generates a symbol table, which contains a list of lexemes or tokens.
7. Which of the following is known as a compiler for a high-level language that runs on one machine and produces code for a different machine?
a) Cross compiler
b) Multipass compiler
c) Optimizing compiler
d) One pass compiler
View Answer
Answer: a
Explanation: So done by the definition.
8. Which of the following is a system program that integrates a program’s individually compiled modules into a form that can be executed?
a) Interpreter
b) Assembler
c) Compiler
d) Linking Loader
View Answer
Answer: d
Explanation: A loader that combines the functionality of a relocation loader with the ability to combine a number of independently compiled program segments.
9. Which of the following is a definition of compiler?
a) Acceptance of a program written in a high-level language and produces an object program
b) Program is put into memory and executes it
c) Translation of assembly language into machine language
d) None of the mentioned
View Answer
Answer: a
Explanation: A compiler is a software (or combination of programs) that converts source code written in one programming language (the source language) into code written in another programming language (the target language) (the target language, often having a binary form known as object code).
10. Which of the following phase of the compiler is Syntax Analysis?
a) Second
b) Third
c) First
d) All of the mentioned
View Answer
Answer: a
Explanation: It is the Second Phase of the Compiler after Lexical Analyzer. It is also called Hierarchical Analysis or Parsing.
11. Which of the following concept of FSA is used in the compiler?
a) Code optimization
b) Code generation
c) Lexical analysis
d) Parser
View Answer
Answer: c
Explanation: Because the lexer performs its analysis by going from one stage to another.
12. Which of the following is a part of a compiler that takes as input a stream of characters and produces as output a stream of words along with their associated syntactic categories?
a) Optimizer
b) Scanner
c) Parser
d) None of the mentioned
View Answer
Answer: b
Explanation: A compiler’s scanner scans a character-based input stream and creates a word-based output stream, with each word identified with its Syntactic category.
13. Let L1 = {w ∈ {0,1}∗ | w has at least as many occurrences
of (110)’s as (011)’s}.
Let L2 = { ∈ {0,1}∗ | w has at least as many occurrences
of (000)’s as (111)’s}.
Which of the following is correct?
a) L2 is regular
b) L1 and L2 are regular
c) L1 is regular but not L2
d) None of them are regular
View Answer
Answer: c
Explanation: Let’s look at the string 011011011011 to see if L1 is regular. The number of times 011 has occurred is four, however, it has also occurred three times. We can also produce a 110 if the string ends with 011. The following string is 110110110110, where 110 appears four times and 011 appears three times, already satisfying the.
14. What is CFG?
a) Regular Expression
b) Compiler
c) Language expression
d) All of the mentioned
View Answer
Answer: b
Explanation: They’re defined by the rule A->b, where A isn’t terminal and b is.
15. Which of the following is a correct statement?
I. For some programming languages, there are parsing algorithms with an O(3) complexity.
II. A recursive programming language can be constructed with static storage allocation.
III. In the context of bottom-up parsing, no L-attributed definition can be evaluated.
IV. Code-improvement modifications can be carried out at both the intermediate and source code levels.
a) I and III
b) I and IV
c) I, II and IV
d) I, II, III and IV
View Answer
Answer: b
Explanation: In recursion, space is used but recursive calls can’t be calculated by the compiler.
16. Which of the following is correct regarding an optimizer Compiler?
a) Optimize the code
b) Is optimized to occupy less space
c) Both of the mentioned
d) None of the mentioned
View Answer
Answer: d
Explanation: An optimising compiler is a computer programme that strives to minimise or maximise specific characteristics of an executable programme.
17. Which of the following error can Compiler diagnose?
a) Logical errors only
b) Grammatical and logical errors
c) Grammatical errors only
d) All of the mentioned
View Answer
Answer: c
Explanation: Only syntactical errors can be detected by the compiler.
18. In which of the following phase of the compiler is Lexical Analyser?
a) Second
b) Third
c) First
d) All of the mentioned
View Answer
Answer: c
Explanation: Lexical Analyzer is the First Phase of the Compiler.
19. Which of the following does an address code involve?
a) No unary operators
b) Exactly 3 address
c) At most Three address
d) None of the mentioned
View Answer
Answer: d
Explanation: In computer science, three-address is an intermediate code used by optimizing compilers to aid in the implementation of code-improving transformations.
20. An object module for a group of programs that were compiled separately is handed to a linker. Which of the following about an object module isn’t true?
a) Relocation bits
b) Names and locations of all external symbols denied in the object module
c) Absolute addresses of internal symbols
d) Object code
View Answer
Answer: c
Explanation: A linker, sometimes known as a link editor, is a computer program that merges one or more object files generated by a compiler into a single executable, library, or another object file.
21. Characters are grouped into tokens in which of the following phase of the compiler design?
a) Code generator
b) Lexical analyzer
c) Parser
d) Code optimization
View Answer
Answer: b
Explanation: Gives tokens as output
22. Why Generation of intermediate code based on an abstract machine model is useful in compilers?
a) Writing for intermediate code generation
b) Portability of the front end of the compiler
c) Implementation of lexical analysis and syntax analysis is made easier
d) All of the mentioned
View Answer
Answer: c
Explanation: Intermediate code generator receives input from its predecessor phase, semantic analyzer, in the form of an annotated syntax tree.
23. Why System program such as compiler are designed?
a) They are Serially usable
b) They are Re-enterable
c) They are Nonreusable
d) All of the mentioned
View Answer
Answer: b
Explanation: Re-enterable is the keyword for compiler being designed.
24. Which of the following technique is used for building cross compilers for other machines?
a) Canadian Cross
b) Mexican Cross
c) X-cross
d) Brazilian Cross
View Answer
Answer: a
Explanation: The Canadian Cross is a technique for building cross compilers for other machines. Given three machines X, Y, and Z, one uses machine X (e.g. running Windows XP on an IA-32 processor) to build a cross compiler that runs on machine Y (e.g. running Mac OS X on an x86-64 processor) to create executables for machine Z.
25. Which of the following can detect an error if a programmer by mistake writes multiplication instead of division?
a) Interpreter
b) Compiler or interpreter test
c) Compiler
d) None of the mentioned
View Answer
Answer: d
Explanation: No Logical errors can’t be detected.
