250+ TOP MCQs on Finite Automata and Answers Quiz Exam

Compilers Multiple Choice Questions & Answers (MCQs) on “Finite Automata”.

1. A language L from a grammar G = { VN, Σ, P, S} is?
a) Set of symbols over VN
b) Set of symbols over Σ
c) Set of symbols over P
d) Set of symbols over S

Answer: b
Clarification: The definition of the grammar is set of symbols over Σ.

2. What is the transitional function of a DFA?
a) Q X Σ→Q
b) Q X Σ→2Q
c) Q X Σ→2n
d) Q X Σ→Qn

Answer: a
Clarification: Q is the finite set and let be a finite set of symbols so Q X Σ fives no of states.

3. What is the transitional function of an NFA?
a) Q X Σ→Q
b) Q X Σ→2Q
c) Q X Σ→2n
d) Q X Σ→Qn

Answer: b
Clarification: Let Q be a finite set and let be a finite set of symbols. Also let be a function from Q to 2Q. All the elements of Q a state, the transition function, q0 the initial state and A the set of accepting states.
Then a nondeterministic finite automaton is a 5-tuple < Q, , q0, , A >.

4. Maximum number of states of a DFA converted from an NFA with nstates is?
a) n
b) n2
c) 2n
d) None of the mentioned

Answer: c
Clarification: Take the NFA with states {qo,q1}, alphabet Σ={a}, initial state q0, transitions δ(q0,a)=q0, δ(q0,a)=q1 and final state q1. It generates the same language as the DFA with the same set of states and alphabet, but transitions δ(q0,a)=q1 and δ(q1,a)=q1.

5. What are the basic limitations of finite state machine?
a) It cannot remember arbitrarily large amount of information
b) In cannot remember state transitions
c) In cannot remember grammar for a language
d) It cannot remember language generated from a grammar

Answer: b
Clarification: Because it does to store its previous state of the transition.

6. The string WWR is not recognized by any FSM because _____________
a) An FSM cannot remember arbitrarily large amount of information
b) An FSM cannot fix the midpoint
c) An FSM cannot match W with WR
d) An FSM cannot remember first and last inputs

Answer: b
Clarification: Palindromes cannot be recognized by FSM.

7. A finite automata recognizes ____________
a) Any Language
b) Context Sensitive Language
c) Context Free Language
d) Regular Language

Answer: d
Clarification: All regular languages are implemented by finite automata.

250+ TOP MCQs on Syntax Analyser and Answers

Compilers Multiple Choice Questions on “Syntax Analyser”.

1. Which phase of the compiler is Syntax Analysis?
a) First
b) Second
c) Third
d) None of the mentioned

Answer: b
Clarification: It is Second Phase Of Compiler after Lexical Analyzer.

2. Syntax Analyser is also known as ___________
a) Hierarchical Analysis
b) Hierarchical Parsing
c) None of the mentioned
d) Hierarchical Analysis & Parsing

Answer: d
Clarification: It is also called as Hierarchical Analysis or Parsing.

3. Syntax Analyser takes Groups Tokens of source Program into Grammatical Production.
a) True
b) False

Answer: a
Clarification: It Groups Tokens of source Program into Grammatical Production.

4. From where it takes its input from?
a) Lexical analyser
b) Syntactic Analyser
c) Semantic Analyser
d) None of the mentioned

Answer: a
Clarification: A syntax analyzer or parser takes the input from a lexical analyzer in the form of token streams.

5. Parsers are expected to parse the whole code.
a) True
b) False

Answer: a
Clarification: Parsers are expected to parse the whole code even if some errors exist in the program.

6. A grammar for a programming language is a formal description of _______________
a) Syntax
b) Semantics
c) Structure
d) Library

Answer: c
Clarification: The grammar clearly indicates which type of structure does a program has.

7. Which of these is not true about the Symbol Table?
a) All the labels of the instructions are symbols
b) Table has entry for symbol name address value
c) Perform the processing of the assembler directives
d) Created during pass 1

Answer: c
Clarification: The Symbol table does not ever perform the processing of the assembler derivative.

8. Which of these features of assembler are Machine-Dependent?
a) Instruction formats
b) Addressing modes
c) Program relocation
d) All of the mentioned

Answer: d
Clarification: All of these options are features of assembler which are machine dependent.

9. A compiler can check?
a) Logical Error
b) Syntax Error
c) Both Logical and Syntax Error
d) Not Logical and Syntax Error

Answer: b
Clarification: No compiler can ever check logical errors.

10. The fourth Generation computer was made up of ______________
a) Transistor
b) Vacuum tubes
c) Chips
d) Microprocessor chips

Answer: d
Clarification: It is the only way to increase its throughput.

250+ TOP MCQs on LR Parser and Answers

Compilers Multiple Choice Questions & Answers (MCQs) on “LR Parser”.

1. What is terminal table?
a) Contains all constants in the program
b) Is a permanent table of decision rules in the form of patterns for matching with the uniform symbol table to discover syntactic structure
c) Consist of a full or partial list of the token is as they appear in the program created by lexical analysis and used for syntax analysis and interpretation
d) Is a permanent table which lists all keywords and special symbols of the language in symbolic form

Answer: d
Clarification: A permanent database that has entry for each terminal symbols such as arithmetic operators, keywords, punctuation characters such as ‘;’, ‘,’etc Fields: Name of the symbol.

2. Advantage of incorporating the macro-processor into pass 1 is that _________
a) Many functions have to be implemented twice
b) Functions are combined not necessarily creating intermediate files as output from the macro-processor and input to the assembler
c) More flexibility is provided to the programmer in that he may use all the features of the assembler in conjunction with macros
d) All of the mentioned

Answer: d
Clarification: A general-purpose macro processor or general purpose pre-processor is a macro designed primarily for string manipulation, macro definition.

3. Which of the following is a phase of a compilation process?
a) Lexical Analysis
b) Code Generation
c) Lexical Analysis & Code Generation
d) None of the mentioned

Answer: c
Clarification: Lexical analysis and code generation is a phase of compilation process.

4. System program such as compiler are designed so that they are _________
a) Re-enterable
b) Non reusable
c) Serially usable
d) None of the mentioned

Answer: a
Clarification: Re-enterable is the keyword for compiler being designed.

5. A series of statements explaining how the data is to be processed is called _________
a) Assembly
b) Machine
c) COBOL
d) Program

Answer: d
Clarification: A program is a sequence of instructions, written to perform a task by computer. It requires programs to function, typically executing the program’s instructions in a central processor.

6. A loader is a program that _________
a) Program that places functions into memory and prepares them for execution
b) Program that automates the translation of assembly language into machine language
c) Program accepting another program written in a high level language and produces as object program
d) None of the mentioned

Answer: a
Clarification: A loader is the part of an operating system that is responsible for loading programs and libraries. It is important in the process of placing the programs into memory and executing them.

7. A system program that setup an executable program in main memory ready for execution is?
a) Assembler
b) Linker
c) Loader
d) Load and go

Answer: c
Clarification: A loader is the part of an operating system that is responsible for loading programs and libraries. It is one of the essential stages in the process of starting a program, as it places programs into memory and prepares them for execution.

8. Which of the following system program forgoes the production of object code to generate absolute machine code and load it into the physical main storage location from which it will be executed immediately upon completion of the assembly?
a) Two pass assembler
b) Load and go assembler
c) Macro processor
d) Linker

Answer: b
Clarification: A load and go assembler generates absolute machine code and loads it to physical memory.

9. Uniform symbol table _________
a) Has all constants in the program
b) Permanent table of rules in the form of patterns for matching with the uniform symbol table to discover syntactic structure
c) Consists of full or partial list of the tokens as they appear in the program created by Lexical analysis and used for syntax analysis and interpretation
d) A permanent table which has all key words and special symbols of the language in symbolic form

Answer: c
Clarification: Each pass scans the program, the first pass generates the symbol table and the second pass generates the machine code.

10. Assembler is a program that _________
a) Puts programs into memory and executes them
b) Translates the assembly language into machine language
c) Writes in high level language and produces an object program
d) None of the mentioned

Answer: b
Clarification: An assembler is a program that takes basic computer instructions and converts them into a pattern of bits that the computer’s processor can use to perform its basic operations.

250+ TOP MCQs on Implementation of Increment and Decrement

Compilers Questions and Answers for Aptitude test on “Implementation of Increment and Decrement”.

1. In C programming language, which of the following type of operators have the highest precedence?
a) Relational Operators
b) Equality Operators
c) Logical Operators
d) Arithmetic Operators

Answer: d
Clarification: No other operator has higher precedence than arithmetic operator.

2. Which of the following operators has the highest precedence?
a) Unary +
b) *
c) >=
d) ==

Answer: a
Clarification: Unary operators have max precedence in over all other arithmetic operators.

3. If i=1 j=2,k=3, then what is the value of the following expression?

a) 6
b) 5
c) 1
d) 0

Answer: c
Clarification: !((2+3)>(1+5))
!(5>6)
Since the condition is false hence !(0)
And complement of 0 is 1.

4. The expression 5 – 2 – 3 * 5 – 2 will evaluate to 18, if – is left associative and _____________
a) * has precedence over *
b) * has precedence over –
c) – has precedence over *
d) – has precedence over –

Answer: c
Clarification: if – has precedence over* and if it associates from the right.

5. Coercion _____________
a) Takes place over an assignment operator
b) Operator has operands of various types
c) None of the mentioned
d) Takes place over an assignment operator & Operator has operands of various types

Answer: d
Clarification: Conversion between compatible types.

6. Choose the correct statement.
a) Expressions evaluated at compile time
b) String constants concatenated at compile time
c) None of the mentioned
d) Both of the mentioned

Answer: d
Clarification: The statements are true.

7. Which of the following operators takes only integer operands?
a) +
b) *
c) /
d) %

Answer: d
Clarification: Two integers are taken to be input.

8. Pick the operators that associate from the left.
a) +
b) ,
c) <
d) All of the mentioned

Answer: d
Clarification: They are left associative.

9. Pick the operators that associate from the right.
a) ?:
b) +=
c) =
d) All of the mentioned

Answer: d
Clarification: They are right associative.

10. Pick the operators that associate from left to right.
a) &&
b) ?:
c) ,
d) All of the mentioned

Answer: d
Clarification: They left to right associative.

250+ TOP MCQs on Finite Automata and Answers

Compilers Multiple Choice Questions & Answers (MCQs) on “Finite Automata”.

1. Which of the following statement is true for Dead State?
a) It cannot be reached anytime
b) There is no necessity of the state
c) If control enters no way to come out from the state
d) If control enters FA deads

Answer: c
Clarification: It is a rejecting state for if the control enters it reaches the dead end and cannot reach an accepting state.

2. Which of the following statement is true for Moore Machine?
a) Output depends on present state
b) Output depends on present input
c) Output depends on present state and present input
d) Output depends on present state and past input

Answer: a
Clarification: The definition states that moore machines output is determined by the current state only.

3. Which of the following statement is true for Mealy Machine?
a) Output depends on present state
b) Output depends on present input
c) Output depends on present state and present input
d) Output depends on present state and past input

Answer: c
Clarification: The definition states that its output is determined by current state and current input.

4. Which is true for in accessible state?
a) It cannot be reached anytime
b) There is no necessity of the state
c) If control enters no way to come out from the state
d) If control enters FA deads

Answer: a
Clarification: The very meaning of in accessible state is that it cannot be reached at any point of time.

5. In Mealy Machine O/P is associated with ____________
a) Present state
b) Next state
c) Input
d) None of the mentioned

Answer: b
Clarification: The definition states that its output is determined by current state and current input.

6. In Moore Machine O/P is associated with ____________
a) Present state
b) Next state
c) Input
d) None of the mentioned

Answer: a
Clarification: The definition states that moore machines output is determined by the current state only.

7. Which type of string is accepted by the following finite automata?
a) All string
b) Null string
c) No string
d) None of the mentioned

Answer: b
Clarification: Null strings are not accepted by finite automata.

8. Myhill-Nerode Theorem is used for __________
a) Minimization of DFA
b) Maximization of NFA
c) Conversion of NFA
d) Conversion of DFA

Answer: a
Clarification: Myhill–Nerode theorem provides a necessary and sufficient condition for a language to be regular. The Myhill–Nerode theorem can be generalized to trees. And used for minimization of DFA.

250+ TOP MCQs on Syntax Analyser and Answers

Compilers Multiple Choice Questions & Answers (MCQs) on “Syntax Analyser”.

1. Select a Machine Independent phase of the compiler.
a) Syntax Analysis
b) Intermediate Code generation
c) Lexical Analysis
d) All of the mentioned

Answer: d
Clarification: All of them work independent of a machine.

2. A system program that combines the separately compiled modules of a program into a form suitable for execution?
a) Assembler
b) Compiler
c) Linking Loader
d) Interpreter

Answer: c
Clarification: A loader which combines the functions of a relocating loader with the ability to combine a number of program segments that have been independently compiled.

3. Which of the following system software resides in the main memory?
a) Text Editor
b) Assembler
c) Linker
d) Loader

Answer: d
Clarification: Loader is used to loading programs.

4. Output file of Lex is __________ the input file is Myfile.
a) Myfile.e
b) Myfile.yy.c
c) Myfile.lex
d) Myfile.obj

Answer: b
Clarification: This Produce the filr “myfile.yy.c” which we can then compile with g++.

5. Type checking is normally done during ____________
a) Lexical Analysis
b) Syntax Analysis
c) Syntax Directed Translation
d) Code generation

Answer: c
Clarification: It is the function of Syntax directed translation.

6. Suppose One of the Operand is String and other is Integer then it does not throw error as it only checks whether there are two operands associated with ‘+’ or not.
a) True
b) False

Answer: a
Clarification: Syntax analyser does not check the type of the operand.

7. In Short Syntax Analysis Generates Parse Tree.
a) True
b) False

Answer: a
Clarification: Short Syntax Analysis generates a parse tree.

8. By whom is the symbol table created?
a) Compiler
b) Interpreter
c) Assembler
d) None of the mentioned

Answer: a
Clarification: Symbol table is created by the compiler which contains the list of lexemes or tokens.

9. What does a Syntactic Analyser do?
a) Maintain Symbol Table
b) Collect type of information
c) Create parse tree
d) None of the mentioned

Answer: c
Clarification: Syntax analyzer will just create a parse tree. Semantic Analyzer checks the meaning of the string parsed.

10. Semantic Analyser is used for?
a) Generating Object code
b) Maintaining symbol table
c) Generating Object code & Maintaining symbol table
d) None of the mentioned

Answer: c
Clarification: Maintaining the Symbol Table for each block.
Source Program for Semantic Errors.
Collects Type Information for Code Generation.
Reporting compile-time errors in the code Generating the object code (e.g., assembler or intermediate code).