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.

51.

Give a production grammar for the language L = {x/x ∈ (a,b)*, the number of a’s in x is multiple of 3}.(a) {S->bS, S->b,S->aA, S->bA, A->aB, B->bB, B->aS, S->a}(b) {S->aS,S->bA,A->bB,B->bBa,B->bB}(c) {S->aaS,S->bbA,A->bB,B->ba}(d) None of the mentionedI got this question by my college professor while I was bunking the class.My doubt stems from Regular Grammar in chapter Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Right OPTION is (a) {S->BS, S->B,S->aA, S->bA, A->AB, B->bB, B->aS, S->a}

The explanation: The above given condition is satisfied by

S->bS S->B

S->aA s->bA A->aB B->bB

B->aS S->a.

52.

Give a production grammar that specified language L = {ai b2i >= 1}.(a) {S->aSbb,S->abb}(b) {S->aSb, S->b}(c) {S->aA,S->b,A->b}(d) None of the mentionedThe question was posed to me during an online interview.Asked question is from Regular Grammar topic in division Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Correct OPTION is (a) {S->ASBB,S->abb}

The BEST I can explain: S->aSbb, S->abb give a^Ia’s and b^2i b’s.

53.

Let the class of language accepted by finite state machine be L1 and the class of languages represented by regular expressions be L2 then?(a) L1=L2(c) L1 U L2 = .*(d) L1=L2This question was posed to me during an online exam.This is a very interesting question from Regular Grammar in division Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Right option is (d) L1=L2

The best EXPLANATION: FINITE state MACHINE and regular expression have same power to express a LANGUAGE.

54.

How many strings of length less than 4 contains the language described by the regular expression (x+y)*y(a+ab)*?(a) 7(b) 10(c) 12(d) 11This question was posed to me during an online exam.This intriguing question comes from Regular Grammar topic in division Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Correct OPTION is (d) 11

The explanation: String of LENGTH 0 = 1

string of length 1 = 4

string of length 2 = 3

string of length 3 = 3.

55.

Consider the grammar given below E? E+E | E*E | E-E | E/E | E^E | (E) | id Assume that + and ^ have the same but least precedence, * and / have the next higher precedence but the same precedence and finally ^ has the highest precedence. Assume + and ^ associate to the left like * and / and that ^ associates to the right. Choose the correct for the ordered pairs (^,^), (-,-), (+,+), (*,*) in the operator precedence table constructed for the grammar.(a) All (c) < >, =(d) < > > >I have been asked this question in homework.I would like to ask this question from Context Free Grammar topic in portion Contextfree Grammar and Syntax Analysis of Compiler

Answer»

The correct ANSWER is (d) < > > >

EASIEST explanation: This relation is established of BASIS of the PRECEDENCE of operators.

56.

Which of the following statement is false?(a) The CFG can be converted to Chomsky normal form(b) The CFG can be converted to Greibach normal form(c) CFG is accepted by pushdown automata(d) None of the mentionedThis question was addressed to me in a job interview.I want to ask this question from Context Free Grammar topic in division Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Correct answer is (d) None of the mentioned

Easiest EXPLANATION: All the STATEMENTS follow the RULES.

57.

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) FalseI have been asked this question during an interview.I need to ask this question from Syntax Analyser in division Contextfree Grammar and Syntax Analysis of Compiler

Answer»

The correct choice is (a) True

For explanation: Syntax analyser does not CHECK the TYPE of the OPERAND.

58.

From where it takes its input from?(a) Lexical analyser(b) Syntactic Analyser(c) Semantic Analyser(d) None of the mentionedThe question was asked at a job interview.This interesting question is from Syntax Analyser in portion Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Right choice is (a) Lexical analyser

The EXPLANATION: A syntax analyzer or parser TAKES the input from a lexical analyzer in the FORM of TOKEN STREAMS.

59.

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 posed to me during an internship interview.This intriguing question comes from Right Left Linear Grammar topic in chapter Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Correct option is (B) Right LINEAR GRAMMAR

To explain I would SAY: Right Linear grammar can be TRANSLATE to DFA.

60.

Given the following statements: (i) Recursive enumerable sets are closed under complementation. (ii) Recursive sets are closed under complements. Which is/are the correct statements?(a) I only(b) II only(c) Both I and II(d) Neither I nor IIThis question was addressed to me in homework.My enquiry is from Context Free Grammar topic in section Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Correct answer is (b) II only

The EXPLANATION is: 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.

61.

By whom is the symbol table created?(a) Compiler(b) Interpreter(c) Assembler(d) None of the mentionedI had been asked this question in semester exam.My query is from Syntax Analyser topic in section Contextfree Grammar and Syntax Analysis of Compiler

Answer» CORRECT answer is (a) COMPILER

The explanation is: Symbol table is CREATED by the compiler which CONTAINS the list of LEXEMES or tokens.
62.

A compiler can check?(a) Logical Error(b) Syntax Error(c) Both Logical and Syntax Error(d) Not Logical and Syntax ErrorThis question was posed to me during an interview for a job.My query is from Syntax Analyser in portion Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Correct CHOICE is (b) Syntax Error

The explanation: No COMPILER can ever CHECK logical ERRORS.

63.

Syntax Analyser takes Groups Tokens of source Program into Grammatical Production.(a) True(b) FalseI got this question in an online quiz.This intriguing question comes from Syntax Analyser in section Contextfree Grammar and Syntax Analysis of Compiler

Answer»

The correct CHOICE is (a) True

Easy explanation: It GROUPS TOKENS of SOURCE Program into Grammatical Production.

64.

What are the two types of Linear Grammar?(a) Right Linear(b) Left Linear(c) None of the mentioned(d) Right & Left LinearThe question was asked in a national level competition.I need to ask this question from Right Left Linear Grammar topic in division Contextfree Grammar and Syntax Analysis of Compiler

Answer» RIGHT answer is (d) Right & Left Linear

The EXPLANATION is: Linear grammar is of 2 TYPES Left and Right Linear Grammar
65.

In Right-Linear grammars, all productions have the form: A → xB.(a) True(b) FalseI got this question during an online interview.My question is from Right Left Linear Grammar in portion Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Correct answer is (a) True

The EXPLANATION is: Right-Linear GRAMMARS, FOLLOWING are the form of productions: A → xB or A → X where x is some string of TERMINALS.

66.

Select a Machine Independent phase of the compiler.(a) Syntax Analysis(b) Intermediate Code generation(c) Lexical Analysis(d) All of the mentionedI have been asked this question in exam.My enquiry is from Syntax Analyser topic in chapter Contextfree Grammar and Syntax Analysis of Compiler

Answer» RIGHT answer is (d) All of the mentioned

For EXPLANATION: All of them WORK independent of a MACHINE.
67.

The context free grammar S → SS | 0S1 | 1S0 | ɛ generates _________(a) Equal number of 0’s and 1’s(b) Unequal number of 0’s and 1’s(c) Number of 0’s followed by any number of 1’s(d) None of the mentionedI have been asked this question in final exam.I'm obligated to ask this question of Context Free Grammar topic in section Contextfree Grammar and Syntax Analysis of Compiler

Answer»

The correct answer is (a) Equal number of 0’s and 1’s

To EXPLAIN I would say: S->SS

S->0S1S

S->0S11S0

S->0110.

68.

Which of these features of assembler are Machine-Dependent?(a) Instruction formats(b) Addressing modes(c) Program relocation(d) All of thementionedThe question was posed to me in an online interview.This intriguing question comes from Syntax Analyser topic in division Contextfree Grammar and Syntax Analysis of Compiler

Answer»

Right ANSWER is (d) All of thementioned

Explanation: All of these OPTIONS are features of ASSEMBLER which are MACHINE DEPENDENT.

69.

A grammar for a programming language is a formal description of _______________(a) Syntax(b) Semantics(c) Structure(d) LibraryThe question was posed to me by my school principal while I was bunking the class.My query is from Syntax Analyser in portion Contextfree Grammar and Syntax Analysis of Compiler

Answer» CORRECT option is (c) STRUCTURE

Explanation: The grammar CLEARLY indicates which TYPE of structure does a PROGRAM has.
70.

What is CFG?(a) Compiler(b) A language expression(c) Regular Expression(d) None of the mentionedI got this question in quiz.This key question is from Right Left Linear Grammar topic in portion Contextfree Grammar and Syntax Analysis of Compiler

Answer»

The CORRECT ANSWER is (b) A LANGUAGE expression

To explain I would SAY: They are defined by rule A->b where A is non terminal and b is terminal.

71.

Which of the following String can be obtained by the language L = {ai b2i / i >=1}?(a) aaabbbbbb(b) aabbb(c) abbabbba(d) aaaabbbabbThe question was posed to me in examination.Question is taken from Regular Grammar in portion Contextfree Grammar and Syntax Analysis of Compiler

Answer» CORRECT choice is (a) aaabbbbbb

To explain I would say: Above PRODUCTION RULE gives SUPPOSE if 3 a’s the CORRESPONDING b’s are 6 b’s.
72.

Type checking is normally done during ____________(a) Lexical Analysis(b) Syntax Analysis(c) Syntax Directed Translation(d) Code generationI have been asked this question during an interview for a job.My query is from Syntax Analyser topic in portion Contextfree Grammar and Syntax Analysis of Compiler

Answer» RIGHT CHOICE is (c) Syntax DIRECTED TRANSLATION

For explanation: It is the function of Syntax directed translation.