Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Which of the following is true?(a) All subsets of a regular set are always regular(b) All finite subsets of non-regular set are always regular(c) Union of two non regular set of language is not regular(d) Infinite times union of finite set is always regularI got this question in an internship interview.This key question is from Regular Grammar in chapter Contextfree Grammar and Syntax Analysis of Compiler

Answer» CORRECT OPTION is (b) All finite subsets of non-regular SET are always regular

To ELABORATE: NONE.
2.

Which of the following is true?(a) (01)*0 = 0(10)*(b) (0+1)*0(0+1)*1(0+1) = (0+1)*01(0+1)*(c) (0+1)*01(0+1)*+1*0* = (0+1)*(d) All of the mentionedThe question was asked in an international level competition.My doubt is from Regular Grammar in section Contextfree Grammar and Syntax Analysis of Compiler

Answer» CORRECT OPTION is (d) All of the mentioned

Easy EXPLANATION: NONE.
3.

A CFG is closed under _________(a) Union(b) Kleene star(c) Concatenation(d) None of the mentionedThe question was posed to me during an interview for a job.Enquiry is from Context Free Grammar topic in chapter Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Correct CHOICE is (d) None of the MENTIONED

Easy explanation: CFG is closed under the above mentioned 3 OPERATIONS.

4.

Grammars that can be translated to DFAs is ___________(a) Left linear grammar(b) Right linear grammar(c) Generic grammar(d) All of the mentionedThis question was addressed to me in final exam.I'd like to ask this question from Context Free Grammar in section Contextfree Grammar and Syntax Analysis of Compiler

Answer» CORRECT CHOICE is (B) Right LINEAR GRAMMAR

Best explanation: Right linear grammar can be translated to the DFAs.
5.

A context free language is called ambiguous if _________(a) It has 2 or more left derivations for some terminal string ѡ є L (G)(b) It has 2 or more right derivations for some terminal string ѡ є L (G)(c) It has 2 or more left & right derivations for some terminal string ѡ є L (G)(d) None of the mentionedI got this question during an internship interview.This interesting question is from Context Free Grammar topic in section Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Right answer is (b) It has 2 or more right derivations for some terminal string ѡ є L (G)

For EXPLANATION I WOULD say: A context-free grammar (CFG) is a SET of recursive rewriting rules (or productions) USED to generate patterns of strings.

6.

Output file of Lex is __________ the input file is Myfile.(a) Myfile.e(b) Myfile.yy.c(c) Myfile.lex(d) Myfile.objI got this question in final exam.My question is taken from Syntax Analyser topic in portion Contextfree Grammar and Syntax Analysis of Compiler

Answer» RIGHT OPTION is (b) Myfile.yy.c

For explanation: This Produce the filr “myfile.yy.c” which we can then COMPILE with G++.
7.

A Push Down Automata is if there is at most one transition applicable to each configuration?(a) Deterministic(b) Non deterministic(c) Finite(d) Non finiteI got this question in a job interview.This intriguing question originated from Right Left Linear Grammar in portion Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Right ANSWER is (a) Deterministic

The EXPLANATION: In EVERY SITUATION, only one transition is available as continuation then the result is deterministic push down AUTOMATA.

8.

Which of the following statement is true?(a) Every language that is defined by regular expression can also be defined by finite automata(b) Every language defined by finite automata can also be defined by regular expression(c) We can convert regular expressions into finite automata(d) All of the mentionedThe question was posed to me by my school principal while I was bunking the class.My enquiry is from Right Left Linear Grammar in division Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Right option is (d) All of the mentioned

For explanation I would SAY: All these STATEMENTS are true w.r.t regular expression.

9.

Automaton accepting the regular expression of any number of a’ s is ___________(a) a*(b) ab*(c) (a/b)*(d) a*b*cThis question was posed to me during an online interview.This interesting question is from Context Free Grammar in division Contextfree Grammar and Syntax Analysis of Compiler

Answer» CORRECT CHOICE is (a) a*

The EXPLANATION is: It GIVES any NUMBER of a’s.
10.

Which phase of the compiler is Syntax Analysis?(a) First(b) Second(c) Third(d) None of the mentionedI had been asked this question during an interview.I need to ask this question from Syntax Analyser topic in chapter Contextfree Grammar and Syntax Analysis of Compiler

Answer» CORRECT answer is (b) Second

To explain I WOULD SAY: It is Second Phase Of COMPILER after LEXICAL Analyzer.
11.

Transition of finite automata is ___________(a) Finite Diagram(b) State Diagram(c) Node Diagram(d) E-R DiagramThe question was asked during an online exam.This is a very interesting question from Right Left Linear Grammar in section Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Correct CHOICE is (b) STATE Diagram

For explanation I would say: Transition of FINITE automata is Finite Diagram.

12.

Left Linear grammar can be converted to Right Linear grammar.(a) Yes(b) NoThe question was asked in a national level competition.This intriguing question comes from Right Left Linear Grammar topic in division Contextfree Grammar and Syntax Analysis of Compiler

Answer»

The correct CHOICE is (a) Yes

To EXPLAIN: Since right-linear GRAMMARS are regular, it follows that left-linear grammars are ALSO regular.

13.

A regular Grammar is a_________(a) CFG(b) Non CFG(c) English Grammar(d) None of the mentionedI got this question in an online quiz.My question is from Context Free Grammar topic in division Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Correct answer is (a) CFG

Explanation: Regular GRAMMAR is CFG. It restricts its rules to a single NON terminal on LEFT hand side.

14.

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 1I had been asked this question in an interview for internship.My doubt stems from Syntax Analyser in portion Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Correct answer is (c) PERFORM the PROCESSING of the assembler directives

To EXPLAIN: The Symbol table does not EVER perform the processing of the assembler derivative.

15.

Semantic Analyser is used for?(a) Generating Object code(b) Maintaining symbol table(c) Generating Object code & Maintaining symbol table(d) None of the mentionedI had been asked this question in my homework.This intriguing question originated from Syntax Analyser topic in section Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Right answer is (C) GENERATING Object code & Maintaining symbol table

For explanation: 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).

16.

Regular expression is __________(a) Type 0 language(b) Type 1 language(c) Type 2 language(d) Type 3 languageThis question was posed to me in examination.Enquiry is from Regular Grammar in section Contextfree Grammar and Syntax Analysis of Compiler

Answer»

The CORRECT ANSWER is (a) Type 0 language

Explanation: ACCORDING to the Chomsky HIERARCHY.

17.

A language is regular if and only if?(a) Accepted by DFA(b) Accepted by PDA(c) Accepted by LBA(d) Accepted by Turing machineI had been asked this question in an online interview.Origin of the question is Regular Grammar in chapter Contextfree Grammar and Syntax Analysis of Compiler

Answer»

The CORRECT answer is (a) ACCEPTED by DFA

To explain: All of above machine can ACCEPT regular language but all STRING accepted by machine is regular only for DFA.

18.

Assume statements S1 and S2 defined as: S1: L2-L1 is recursive enumerable where L1 and L2 are recursive and recursive enumerable respectively. S2: The set of all Turing machines is countable. Which of the following is true?(a) S1 is correct and S2 is not correct(b) Both S1 and S2 are correct(c) Both S1 and S2 are not correct(d) S1 is not correct and S2 is correctI have been asked this question in an online quiz.My doubt is from Context Free Grammar in section Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Right CHOICE is (b) Both S1 and S2 are CORRECT

For explanation: The assumptions of statement S1 and S2 are correct.

19.

Push down automata accepts which language?(a) Context sensitive language(b) Context free language(c) Recursive language(d) None of the mentionedThe question was asked in final exam.The above asked question is from Context Free Grammar topic in portion Contextfree Grammar and Syntax Analysis of Compiler

Answer»

The CORRECT choice is (B) Context free language

Easy EXPLANATION: PDA ACCEPTS CFG.

20.

In Short Syntax Analysis Generates Parse Tree.(a) True(b) FalseI had been asked this question during an interview for a job.This interesting question is from Syntax Analyser topic in chapter Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Right answer is (a) True

For explanation I would say: SHORT SYNTAX ANALYSIS generates a PARSE tree.

21.

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) InterpreterThis question was addressed to me in a job interview.I'm obligated to ask this question of Syntax Analyser topic in division Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Right answer is (c) Linking Loader

The BEST explanation: 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.

22.

What is Regular grammar?(a) Context free grammar(b) Non context free grammar(c) English grammar(d) None of the mentionedI got this question by my school principal while I was bunking the class.This key question is from Regular Grammar in section Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Correct answer is (a) CONTEXT FREE grammar

To EXPLAIN I would SAY: REGULAR grammar is subset of context free grammar.

23.

Which of these does not belong to CFG?(a) Terminal Symbol(b) Non terminal Symbol(c) Start symbol(d) End SymbolThis question was addressed to me in final exam.My question is from Context Free Grammar topic in division Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Right choice is (d) END SYMBOL

The explanation is: CFG CONSISTS of terminal non terminal start symbol set of production RULES but does not have an end symbol.

24.

Which of the following conversion is not possible (algorithmically)?(a) Regular grammar to CFG(b) NDFA to DFA(c) NDPDA to DPDA(d) NDTM to DTMI got this question during an online exam.The doubt is from Context Free Grammar topic in portion Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Right CHOICE is (C) NDPDA to DPDA

The explanation is: Not every NDPDA has an equivalent deterministic PDA.

25.

Which of the following system software resides in the main memory?(a) Text Editor(b) Assembler(c) Linker(d) LoaderThe question was asked during an interview.I would like to ask this question from Syntax Analyser in chapter Contextfree Grammar and Syntax Analysis of Compiler

Answer»

The correct choice is (d) LOADER

The best explanation: Loader is USED to LOADING PROGRAMS.

26.

Parsers are expected to parse the whole code.(a) True(b) FalseI got this question during an internship interview.I would like to ask this question from Syntax Analyser in section Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Right option is (a) True

The EXPLANATION: Parsers are expected to PARSE the whole CODE even if some ERRORS exist in the program.

27.

L and ~L are recursive enumerable then L is?(a) Regular(b) Context free(c) Context sensitive(d) RecursiveThe question was posed to me in final exam.I'm obligated to ask this question of Regular Grammar in section Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Right option is (d) RECURSIVE

For EXPLANATION: If L is recursive ENUMERABLE and its COMPLEMENT too if and only if L is recursive.

28.

What does a Syntactic Analyser do?(a) Maintain Symbol Table(b) Collect type of information(c) Create parse tree(d) None of the mentionedI got this question in my homework.The origin of the question is Syntax Analyser topic in section Contextfree Grammar and Syntax Analysis of Compiler

Answer»

The correct option is (c) Create PARSE TREE

For explanation: SYNTAX analyzer will just create a parse tree. Semantic Analyzer checks the meaning of the string PARSED.

29.

Which of the following statement is false?(a) In derivation tree, the label of each leaf node is terminal(b) In derivation tree, the label of all nodes except leaf nodes is a variable(c) In derivation tree, if the root of a sub tree is X then it is called –tree(d) None of the mentionedI got this question in unit test.I would like to ask this question from Context Free Grammar in portion Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Correct answer is (d) NONE of the mentioned

Easy explanation: All of them are true REGARDING a derivation tree.

30.

A Regular Grammar is any right-linear or left-linear grammar.(a) True(b) FalseThis question was addressed to me in examination.I'd like to ask this question from Right Left Linear Grammar topic in division Contextfree Grammar and Syntax Analysis of Compiler

Answer» CORRECT CHOICE is (a) True

To ELABORATE: As it turns out the languages that can be GENERATED by Regular GRAMMARS is equivalent to those that can be specified by Regular Expressions.
31.

Which of the following is not a regular expression?(a) [(a+b)*-(aa+bb)]*(b) [(0+1)-(0b+a1)*(a+b)]*(c) (01+11+10)*(d) (1+2+0)*(1+2)*This question was addressed to me in my homework.Origin of the question is Regular Grammar topic in chapter Contextfree Grammar and Syntax Analysis of Compiler

Answer»

The CORRECT choice is (B) [(0+1)-(0b+a1)*(a+b)]*

BEST EXPLANATION: Except [(0+1)-(0b+a1)*(a+b)]* all are regular EXPRESSION.

32.

Recursively enumerable languages are not closed under ______________(a) Union(b) Intersection(c) Complementation(d) ConcatenationI have been asked this question in an international level competition.The query is from Context Free Grammar topic in portion Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Right CHOICE is (C) Complementation

To explain: RECURSIVE languages are closed under the FOLLOWING operations.

The Kleene star L * of L

the concatenation L * o P of L and P

the union L U P

the intersection L ∩ P.

33.

If P & R are regular and also given that if PQ=R, then?(a) Q has to be regular(b) Q cannot be regular(c) Q need not be regular(d) Q has to be a CFLThe question was asked in unit test.My question is based upon Context Free Grammar topic in portion Contextfree Grammar and Syntax Analysis of Compiler

Answer»

The CORRECT choice is (c) Q NEED not be REGULAR

Easiest explanation: If two regular languages when COMBINED do not always PRODUCE a regular language.

34.

The context free grammar S → A111|S1, A → A0 | 00 is equivalent to _________(a) {0^n1^m | n=2, m=3}(b) {0^n1^m | n=1, m=5}(c) {0^n1^m | n should be greater than two and m should be greater than four}(d) None of the mentionedThis question was posed to me during an internship interview.Query is from Context Free Grammar topic in portion Contextfree Grammar and Syntax Analysis of Compiler

Answer» RIGHT CHOICE is (a) {0^n1^m | n=2, m=3}

EASY explanation: S-> A111

S->00111 (A->00).
35.

A language is regular if and only if it is accepted by finite automata.(a) The given statement statement is true(b) Given statement is false(c) Statement is partially true(d) None of the mentionedI had been asked this question in an online interview.I would like to ask this question from Right Left Linear Grammar in chapter Contextfree Grammar and Syntax Analysis of Compiler

Answer» RIGHT CHOICE is (a) The given statement statement is true

To explain I would SAY: Regular Language is accepted by FINITE Automata. EVERY regular language is Context free.
36.

Non-Linear grammar has two non-terminals on the right-hand side.(a) True(b) FalseThe question was asked by my college professor while I was bunking the class.My enquiry is from Right Left Linear Grammar topic in portion Contextfree Grammar and Syntax Analysis of Compiler

Answer»

The correct OPTION is (a) True

To explain I WOULD SAY: The above STATED grammar is non-linear because it has two non-terminals on the right-hand side.

37.

Let R1 and R2 be regular sets defined over alphabet ∑ then?(a) R1 UNION R2 is regular(b) R1 INTERSECTION R2 is regular(c) ∑ INTERSECTION R2 IS NOT REGULAR(d) R2* IS NOT REGULARI got this question in semester exam.The question is from Regular Grammar in section Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Right option is (a) R1 UNION R2 is regular

The EXPLANATION is: Union of 2 regular LANGUAGES is regular.

38.

Regular expressions are closed under _____________(a) Union(b) Intersection(c) Kleene star(d) All of the mentionedI have been asked this question in an interview for job.Question is taken from Regular Grammar topic in section Contextfree Grammar and Syntax Analysis of Compiler

Answer» CORRECT option is (d) All of the mentioned

The best EXPLANATION: According to the DEFINITION of regular EXPRESSION.
39.

Which of the following language accepted by a Push down Automata?(a) Type0(b) Type1(c) Type2(d) Type3I got this question during an interview.I'd like to ask this question from Context Free Grammar topic in division Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Right CHOICE is (C) Type2

The explanation is: A known fact that TYPE 2 grammar is accepted by PDA.

40.

Grammar that produce more than one Parse tree for same sentence is ___________(a) Ambiguous(b) Unambiguous(c) Complementation(d) Concatenation IntersectionThe question was posed to me in examination.My enquiry is from Context Free Grammar in chapter Contextfree Grammar and Syntax Analysis of Compiler

Answer»

The CORRECT choice is (a) Ambiguous

Easy explanation: An ambiguous GRAMMAR is one for which there is more than one PARSE tree for a single sentence.

41.

What is the idea of automation with a stack as auxiliary storage?(a) Finite automata(b) Push Down Automata(c) Deterministic Automata(d) None of the mentionedThe question was asked during an interview.My question is taken from Right Left Linear Grammar in section Contextfree Grammar and Syntax Analysis of Compiler

Answer» RIGHT choice is (b) PUSH Down Automata

Easy EXPLANATION: Push Down Automata manipulate the STACK as a part of performing a transition.
42.

Regular Grammars generate Regular Languages.(a) True(b) FalseI have been asked this question by my school principal while I was bunking the class.Enquiry is from Right Left Linear Grammar topic in division Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Right CHOICE is (a) True

To elaborate: That’s why they are CALLED regular LANGUAGES.

43.

Which Grammar is it?(a) Right Linear(b) Left Linear(c) None of the mentioned(d) Right & Left LinearThe question was posed to me by my school teacher while I was bunking the class.This is a very interesting question from Right Left Linear Grammar in section Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Right option is (B) Left Linear

For EXPLANATION: In Left-Linear GRAMMARS, all productions have the form: A→Bx or A→ x where x is some string of terminals.

44.

Linear grammar has more than one non-terminal on the right-hand side.(a) True(b) FalseThe question was asked in an interview for internship.The doubt is from Right Left Linear Grammar topic in section Contextfree Grammar and Syntax Analysis of Compiler

Answer»

The CORRECT OPTION is (a) True

The explanation: Grammar is linear because no RULE has more than one NON terminal on the right-hand SIDE.

45.

Syntax Analyser is also known as ___________(a) Hierarchical Analysis(b) Hierarchical Parsing(c) None of the mentioned(d) Hierarchical Analysis & ParsingThis question was addressed to me by my college director while I was bunking the class.Asked question is from Syntax Analyser topic in section Contextfree Grammar and Syntax Analysis of Compiler

Answer» RIGHT answer is (d) Hierarchical Analysis & Parsing

The best I can EXPLAIN: It is ALSO CALLED as Hierarchical Analysis or Parsing.
46.

A context free language is called ambiguous if?(a) It has 2 or more than 2 left derivations for some terminal string ѡ є L (G)(b) It has 2 or more than 2 right derivations for some terminal string ѡ є L (G)(c) It has 2 or more than 2 left and right derivations for some terminal string ѡ є L (G)(d) None of the mentionedThis question was posed to me during an online exam.My doubt is from Right Left Linear Grammar in section Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Correct answer is (c) It has 2 or more than 2 left and RIGHT derivations for some terminal string ѡ є L (G)

Easiest explanation: When two or more Left and right most DERIVATIVE occur the grammar turn ambiguous .

47.

The regular expression denote a language comprising all possible strings of even length over the alphabet (0,1) is?(a) 1 + 0(1+0)*(b) (0+1)(1+0)*(c) (1+0)(d) (00+0111+10)*The question was posed to me in final exam.Origin of the question is Regular Grammar in portion Contextfree Grammar and Syntax Analysis of Compiler

Answer» CORRECT choice is (d) (00+0111+10)*

The best I can explain: The CONDITION is satisfied by 00 or 0111 or 10 or iterations of these.
48.

The production Grammar is {S->aSbb, S->abb} is?(a) type-3 grammar(b) type-2 grammar(c) type-1 grammar(d) type-0 grammarI got this question in my homework.The query is from Regular Grammar topic in section Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Right OPTION is (B) type-2 GRAMMAR

To explain I would say: Type 2 grammar satisfies this production grammar.

49.

The fourth Generation computer was made up of ______________(a) Transistor(b) Vacuum tubes(c) Chips(d) Microprocessor chipsThis question was addressed to me during an online exam.I'd like to ask this question from Syntax Analyser topic in chapter Contextfree Grammar and Syntax Analysis of Compiler

Answer» CORRECT OPTION is (d) Microprocessor chips

To explain: It is the only WAY to increase its THROUGHPUT.
50.

Which of the following identity is wrong?(a) R + R = R(b) (R*)* = R*(c) ƐR = Rɛ = R(d) ØR = RØ = RR*I have been asked this question in a job interview.Origin of the question is Right Left Linear Grammar in section Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Right answer is (d) ØR = RØ = RR*

The best explanation: REGULAR GRAMMAR combined with empty does not give R* instead gives empty.