Compiler Design MCQ - Javatpoint
Compiler Design MCQ - Javatpoint
Compiler Tutorial
Compiler Tutorial
Compiler Introduction Your reading experience, reimagined
Compiler Phases Kindle Paperwhite (8 GB)
Amazon
Compiler Passes
Bootstrapping
Finite State machine
Regular expression
Optimization of DFA
Compiler Design MCQ ← Prev Next →
LEX
1) Users write the programs in which language?
Formal Grammar
BNF Notation
a. Low-level Language
YACC
Context free Grammars b. High-Level Language
For iPhone Silicone Case
Capabilities of CFG
Derivation
c. Decimal-Format For iPhone 14 13 Pro Max Case Luxury Liquid Silic…
AilExpress
Parse Tree d. Middle-Level Language
Ambiguity
Predictive Parsers
Explanation: Users write the program in a high-level language because it is easier to use,
LR parser
understand and remember.
LR(0) Items
SLR(1) Parsing
CLR(1) Parsing
LALR(1) Parsing 2) Which computer program accepts the high-level language and converts it into assembly language?
Parser Generator
a. Interpreter
SDT
Syntax Directed Translation b. Linker
SDT Translation scheme
SDT Implementation
c. Assembler
Intermediate Code d. Compiler
Postfix Notation
Parse and syntax trees Hide Answer Workspace
Three address code
Quadruples
Triples Answer: d. Compiler
Assignment statements
Boolean expressions Explanation: Compiler is a computer program that accepts the code written in a high-level
Flow altering statements language and converts that code into the assembly language.
Postfix translation
Array references
Procedures call
3) Does the compiler program translate the whole source code in one step?
Declarations
Case Statements
a. No
Symbol Tables
Symbol Table b. Depends on the Compiler
DS for symbols tables
c. Don't Know
Scope Information
d. Yes
Administration
Storage Organization
Hide Answer Workspace
Activation Record
Storage Allocation
Block Optimization
Code Generator
a. Parser
b. Code optimizer
c. Code generator
d. Scanner
Answer: d. Scanner
Explanation: Scanner is a subroutine which is called by the compiler program. The scanner
combines the characters and implements them to produce tokens.
Explanation: Linker is a program in the compiler which is required to create a load module.
a. three types
b. four types
c. two types
d. five types
Explanation: In the compiler design, the parser is mainly categorized into top-down parsing and
bottom-up parsing.
8) In which parsing, the parser constructs the parse tree from the start symbol and transforms it into the
input symbol.
a. Bottom-up parsing
b. Top-down parsing
d. Both a and b
Explanation: Top-down parsing is a technique which constructs the parse tree from the start
symbol and transforms it to the input symbol. This type of parsing is also referred to as predictive
or recursive parsing.
c. Right-most derivation
d. Left-most derivation
Explanation: Top-down parser generates the left-most derivation. It constructs the parse tree
from left to right and constructs the left-most derivation of the specified sentence.
c. Right-most derivation
d. Left-most derivation
Explanation: Bottom-up parser generates the right-most derivation in reverse. It constructs the
parse tree from the input string to the root and tries to construct the right-most derivation of the
specified string backward.
a. Operator Precedence
b. SLR
c. Canonical LR
d. LALR
Answer: c. Canonical LR
Explanation: Canonical LR (CLR) is the most powerful parser than LALR and SLR.
a. string character
b. a syntax tree
c. a set of RE
d. a set of tokens
Explanation: Lexical analyzer gives the set of tokens as output. The set of tokens contains
keywords, separators, literals, identifiers, and operators.
13) From the following grammars, which describes the lexical syntax?
a. Lexical Grammar
b. Context-free Grammar
c. Syntactic Grammar
d. Regular Grammar
14) Which grammar gives multiple parse trees for the same string?
a. Unambiguous
b. Regular
c. Ambiguous
a. removing comments
b. removing whitespace
Explanation: Lexical analyzer is used in the compiler for removing the Whitespace and
comments. It is also used in breaking the syntaxes into the set of tokens.
a. Mexeme
b. Lexeme
c. Texeme
d. Pattern
Answer: b. Lexeme
Explanation: Lexemes are the string of alphanumeric characters in a single token. In the source
program, lexemes are characters which are identified by the pattern for a token.
17) Which part of the compiler highly used the grammar concept?
a. Code optimization
b. Code generation
c. Parser
d. Lexical Analysis
Answer: c. Parser
Explanation: The concept of grammar is much used in the parser phase of the compiler.
The parser phase is next to the lexical analysis phase in the compiler. Parser generated the parse
tree using the predefined grammar. The parser has two different techniques for creating a
different parse tree.
18) Which phase of the compiler checks the grammar of the programming?
a. Code Optimization
b. Semantic Analysis
c. Code Generation
d. Syntax Analysis
Explanation: Syntax Analysis is the 2nd phase of the compiler, which checks the given input
string is the correct syntax of the programming language.
a. Yacc
b. Lex
c. Symbol Table
d. Type Checking
a. Syntax Analysis
b. Lexical Analysis
c. Semantic Analysis
d. Code generation
Explanation: The first part of the compiler (lexical analysis) is also known as a scanner. It scans
the characters from the source program and implements them to produce tokens.
a. Code Optimization
b. Semantic Analysis
c. Syntax Analysis
d. Lexical Analysis
Explanation: The phase of the compiler next to the lexical analysis phase is also known as Parser.
Syntax analysis or parser accepts the tokens produced by the lexical analysis and gives the parse
tree in the output.
a. An LALR parser
b. A LR parser
Explanation: Recursive descent parser is a type of top-down parser which generates the parse
tree from top to bottom and reads the input string from left to right.
Explanation: Keywords are firstly recognized during the lexical analysis of the program in the
compiler.
a. sub-terminals
b. half-terminals
c. non-terminals
d. terminals
Answer: d. terminals.
Explanation: All the leaf nodes in the parse tree indicate the terminals. And all the interior nodes
indicate non-terminals.
25) Which graph describes the basic block and successor relationship?
a. Control graph
b. DAG
c. Flow graph
d. Hamilton graph
a. Type 0 language
b. Type 1 language
c. Type 2 language
d. Type 3 language
a. Context-sensitive grammar
b. Context-free grammar
c. Regular grammar
d. All of these
Answer: d. to increase the chances of re-using the machine-independent code optimizer in other
compilers.
Explanation: After semantic analysis, the intermediate code increases the chances of reusing the
machine-independent code optimizer in other compilers.
a. two types
b. three types
c. four types
d. five types
30) The value of which variable is updated inside the loop by a loop-invariant value?
a. loop
b. strength
c. induction
d. invariable
31) Which compiler runs on one machine and generates code for multiple machines?
a. Multipass compiler
b. Cross compiler
c. Optimizing compiler
d. Onepass compiler
Explanation: Cross compiler is a compiler which runs on one machine and generates code for
more than one machine.
c. The execution takes place after the removal of all syntax errors
d. Firstly scans the entire program and then transforms it into machine-understandable code
Explanation: The compiler does not take more time to execute. So, more execution time is not a
characteristic of the compiler.
33) Which phenomenon happens when the non-terminal on the left side is repeated as the first symbol on
the right side?
a. Left-most derivation
b. Left recursion
c. Left factoring
d. Left parsing
Explanation: Left recursion is the process in which non-terminal on the left side of the
production is the same on the right side as the leftmost symbol.
34) In which derivation the right-most non-terminal symbol is replaced at each step?
b. Right claim
c. Rightmost
d. Right non-terminal
35) In which derivation the leftmost non-terminal symbol is replaced at each step?
a. Left recursion
b. Left non-terminal
c. Left pushdown
d. Leftmost
Answer: d. Leftmost
Explanation: The leftmost derivation is that derivation of context-free grammar which replaces
the leftmost non-terminal symbol at each step.
Explanation: Compiler is a computer program that detects grammatical errors, not logical errors.
a. End symbol
b. Start symbol
c. Non-terminal symbol
d. Terminal symbol
Explanation: Context-free grammar is that grammar which consists of the start symbol, set of
terminals, set of non-terminal symbols and the set of productions.
38) Which method merges the multiple loops into the single one?
a. Constant Folding
b. Loop rolling
a. Bottom-up parser
b. Top-down parser
Explanation: Bottom-up parser in the compiler is also called the shift-reduce parser.
40) Which of the following tree is the pictorial identification of the derivation?
a. reduce/reduce
b. shift/reduce
a. Generic Grammar
c. Intermediate Code
a. Turing language
b. Context-sensitive language
c. Context-free language
d. Regular language
Explanation: None
48) Which of the following term is used to keep track of the location where the current values of the name
are stored?
a. Register descriptor
b. Address descriptor
c. Allocation descriptor
d. Flag register
a. Root
b. Interior nodes
c. Leaves
d. Nodes
Explanation: In the compiler, interior nodes are specified by the operator symbol.
51) Which of the following is used in various stages or phases of the compiler?
a. Records
b. Program
c. Symbol Table
d. Table
a. Parse tree
b. Triples
c. Indirect Triples
d. Quadruples
53) In which of the following tree, the leaf indicates the operand, and the interior node represents the
operator.
a. Syntax tree
b. Parser tree
c. Structured tree
d. Sematic tree
Explanation: Syntax tree is a tree in the compiler which represents operands by leaf and operator
by interior nodes.
a. 3- address
b. 2-address
c. address
d. Intermediate code
a. Parse table
b. Input
c. Output
d. Input-Output
56) Which of the following function is called the canonical collection of LR(0) item.
a. FIRST
b. GOTO
c. COMPUTE
d. FOLLOW
57) Which of the following option is not a function of the shift-reduce parser?
a. Reduce
b. Accept
c. Go
d. Shift
Answer: c. Go
Explanation: The shift-reduce parser contains only shift, reduce, error and accept action. That's
why Go is not a function of the shift-reduce parser.
a. Irregular grammar
b. Regular grammar
c. Operator
d. Precedence grammar
← Prev Next →
Feedback
Preparation
Company
Interview
Questions
Company Questions
Trending Technologies
B.Tech / MCA
Learn Java Java Interview Questions This website is developed to help students on Contact Us
various technologies such as Artificial
Learn Data Structures SQL Interview Questions Intelligence, Machine Learning, C, C++, Privacy Policy
Learn C Programming Python Interview Questions Python, Java, PHP, HTML, CSS, JavaScript, Sitemap
Learn C++ Tutorial JavaScript Interview Questions jQuery, ReactJS, Node.js, AngularJS,
Bootstrap, XML, SQL, PL/SQL, MySQL etc. About Me
Learn C# Tutorial Angular Interview Questions
Learn PHP Tutorial Selenium Interview Questions This website provides tutorials with examples,
code snippets, and practical insights, making it
Learn HTML Tutorial Spring Boot Interview Questions suitable for both beginners and experienced
Learn JavaScript Tutorial HR Interview Questions developers.
Learn jQuery Tutorial C++ Interview Questions There are also many interview questions
Learn Spring Tutorial Data Structure Interview Questions which will help students to get placed in the
companies.