Here are 1000 MCQs on Compiler Design (Chapterwise).
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Explanation: No Logical errors can’t be detected.
Chapterwise Multiple Choice Questions on Compiler Design
- Compiler Introduction
- Finite Automata and Regular Expression
- Contextfree Grammar and Syntax Analysis
- Topdown Parsing
- Bottom Up Parsing
- Syntax Directed Definition and Translations
- Symbol Table
- Storage Management
- Error Handling
- Code Optimisation
- Code Generation
1. MCQ on Compiler Introduction
The section contains Compiler Design multiple choice questions and answers on finite automata and regular expressions, cross compilers, lexical analysis and relations.
2. Compiler Design MCQ on Finite Automata and Regular Expression
The section contains Compiler Design questions and answers on lexical analyser, finite automata, nfa with epsilon as well as minimization of dfa, regular expressions and transformation from nfa to dfa.
3. Compiler Design Multiple Choice Questions on Contextfree Grammar and Syntax Analysis
The section contains Compiler Design MCQs on syntax analyser, context free grammar, regular grammar as well as right left grammar.
|
|
4. Compiler Design MCQ on Topdown Parsing
The section contains Compiler Design multiple choice questions and answers on top-down parsing with its predictives.
|
|
5. Compiler Design Multiple Choice Questions on Bottom Up Parsing
The section contains Compiler Design questions and answers on bottom-up parsing, right sentinel grammar, l-r parser and parsing table data structures.
6. Compiler Design MCQ on Syntax Directed Definition and Translations
The section contains Compiler Design MCQs on syntax directed definitions and translations, intermediate code generation, three address, implementation of increment and decrement, array reference and switch cases.
7. Compiler Design Multiple Choice Questions on Symbol Table
The section contains Compiler Design multiple choice questions and answers on symbol table management as well as symbol table organization and run time storage.
|
|
8. Compiler Design MCQ on Storage Management
The section contains Compiler Design questions and answers on storage, stack and static allocations.
|
|
9. Compiler Design Multiple Choice Questions on Error Handling
The section contains Compiler Design MCQs on error handling, lexical phase errors, automatic error recovery with yacc and also l-r phase, predictive parsing error recovery.
|
|
10. Compiler Design MCQ on Code Optimisation
The section contains Compiler Design multiple choice questions and answers on code optimization, elimination of induction variables, eliminating global common subexpressions, loop optimization, unrolling and jamming.
|
|
11. Compiler Design Multiple Choice Questions on Code Generation
The section contains Compiler Design questions and answers on code generation, machine model, using dag as code generation and peephole optimization.
|
|
Wish you the best in your endeavor to learn and master Compilers!