# Multiple choice question for engineering

## Set 1

1. Which of the following derivations does a top-down parser use while parsing an input string?

a) Leftmost derivation

b) Leftmost derivation in reverse

c) Rightmost derivation

d) Rightmost derivation in reverse

### View Answer

2. The process of assigning load addresses to the various parts of the program and adjusting the code and data in the program to reflect the assigned addresses is called

a) Assembly

b) Parsing

c) Relocation

d) Symbol resolution

### View Answer

3. Which of the following statements is false?

a) Left as well as right most derivations can be in Unambiguous grammar

b) An LL(1) parser is a top-down parser

c) LALR is more powerful than SLR

d) Ambiguous grammar can’t be LR(k)

### View Answer

4. Which of the following grammar rules violate the requirements of an operator grammar?

(i) P -> QR

(ii) P -> QsR

(iii) P -> ε

(iV) P -> QtRr

a) (i) only

b) (i) and (iii) only

c) (ii) and (iii) only

d) (iii) and (iv) only

### View Answer

5. Consider the grammar with the following translation rules and E as the start symbol.

A -> A1 #B {A.value = A1.value * B.value}

| B {A.value = B.value}

B-> B1 & F {B.value = B1.value + C.value}

| C {B.value= C.value }

C -> num {C.value = num.value}

Compute E.value for the root of the parse tree for the expression:2 # 3 & 5 # 6 &4.

a) 200

b) 180

c) 160

d) 40

### View Answer

6. Given the following expression grammar:

E -> E * F | F+E | F

F -> F-F | id

which of the following is true?

a) * has higher precedence than +

b) – has higher precedence than *

c) + and — have same precedence

d) + has higher precedence than *

### View Answer

7. Consider a program P that consists of two source modules M1(contains reference to a function defined in M2) and M2 contained in two different files.

a) Edit time

b) Compile time

c) Link time

d) Load time

### View Answer

8. Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar?

a) Removing left recursion only

b) Factoring the grammar alone

c) Factoring & left recursion removal

d) None of the mentioned

### View Answer

9. Assume that the SLR parser for a grammar G has n1 states and the LALR parser for G has n2 states.

a) n1 is necessarily less than n2

b) n1 is necessarily equal to n2

c) n1 is necessarily greater than n2

d) None of the mentioned

### View Answer

10. Match the following.

P. Regular expression 1. Syntax analysis Q. Pushdown automata 2. Code generation R. Dataflow analysis 3. Lexical analysis S. Register allocation 4. Code optimization

a) P-4. Q-1, R-2, S-3

b) P-3, Q-1, R-4, S-2

c) P-3, Q-4, R-1, S-2

d) P-2, Q-1, R-4, S-3

### View Answer

## Set 2

1. A regular expression enables a quick test to determine objects and text strings with undependable values.

a) True

b) False

### View Answer

2. RE can be used only for values of type string and number.

a) True

b) False

### View Answer

3. You can use RE, if you expect the value of a property to change in an unpredictable way each time its run.

a) True

b) False

### View Answer

4. All ___________ Are automatically treated as regular expressions.

a) Programmatic description

b) Window

c) Win Object

d) Collection

### View Answer

5. If a ‘/’ is used before a character that has no special meaning, ‘/’ is ignored.

a) True

b) False

### View Answer

6. The regular expression denote a language comprising all possible strings of even length over the alphabet (0, 1)

a) 1 + 0(1+0)*

b) (0+1) (1+0)*

c) (1+0)

d) (00+0111+10)*

### View Answer

7. The RE gives none or many instances of an x or y is

a) (x+y)

b) (x+y)*

c) (x* + y)

d) (xy)*

### View Answer

## Set 3

1. The RE in which any number of 0′s is followed by any number of 1′s followed by any number of 2′s is

a) (0+1+2)*

b) 0*1*2*

c) 0* + 1 + 2

d) (0+1)*2*

### View Answer

2. The regular expression have all strings of 0′s and 1′s with no two consecutive 0′s is :

a) (0+1)

b) (0+1)*

c) (0+∈) (1+10)*

d) (0+1)* 011

### View Answer

3. The regular expression with all strings of 0′s and 1′s with at least two consecutive 0′s is:

a) 1 + (10)*

b) (0+1)*00(0+1)*

c) (0+1)*011

d) 0*1*2*

### View Answer

4. Which of the following is NOT the set of regular expression R = (ab + abb)* bbab

a) ababbbbab

b) abbbab

c) ababbabbbab

d) abababab

### View Answer

5. String generated by

S->aS/bA,

A->d/ccA

a) aabccd

b) adabcca

c) abcca

d) abababd

### View Answer

6. Consider the production of the grammar S->AA A->aa A->bb Describe the language specified by the production grammar.

a) L = {aaaa,aabb,bbaa,bbbb}

b) L = {abab,abaa,aaab,baaa}

c) L = {aaab,baba,bbaa,bbbb}

d) L = {aaaa,abab,bbaa,aaab}

### View Answer

7. If R is regular language and Q is any language (regular/ non regular), then Pref (Q in R) is _____________

a) Non-regular

b) Equal

c) Infinite

d) Regular

### View Answer

8. The production of the form no terminal → Λ is said to be null production.

a) False

b) True

### View Answer

## Set 4

1. 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) 11

### View Answer

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 mentioned

### View Answer

3. A language is regular if and only if

a) Accepted by DFA

b) Accepted by PDA

c) Accepted by LBA

d) Accepted by Turing machine

### View Answer

4. Regular grammar is

a) Context free grammar

b) Non context free grammar

c) English grammar

d) None of the mentioned

### View Answer

5. 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

c) L1 U L2 = .*

d) L1=L2

### View Answer

6. 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)*

### View Answer

7. Regular expression are

a) Type 0 language

b) Type 1 language

c) Type 2 language

d) Type 3 language

### View Answer

8. 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 regular

### View Answer

9. L and ~L are recursive enumerable then L is

a) Regular

b) Context free

c) Context sensitive

d) Recursive

### View Answer

10. Regular expressions are closed under

a) Union

b) Intersection

c) Kleene star

d) All of the mentioned

### View Answer

## Set 5

1. Consider the production of the grammar S->AA A->aa A->bb Describe the language specified by the production grammar.

a) L = {aaaa,aabb,bbaa,bbbb}

b) L = {abab,abaa,aaab,baaa}

c) L = {aaab,baba,bbaa,bbbb}

d) L = {aaaa,abab,bbaa,aaab}

### View Answer

2. 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 mentioned

### View Answer

3. 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 REGULAR

### View Answer

4. Which of the following String can be obtained by the language L = {ai b2i / i >=1}

a) aaabbbbbb

b) aabbb

c) abbabbba

d) aaaabbbabb

### View Answer

5. 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 mentioned

### View Answer

6. The production Grammar is {S->aSbb, S->abb} is

a) type-3 grammar

b) type-2 grammar

c) type-1 grammar

d) type-0 grammar

### View Answer

7. Regular expression (x/y)(x/y) denotes the set

a) {xy,xy}

b) {xx,xy,yx,yy}

c) {x,y}

d) {x,y,xy}

### View Answer

8. Regular expression x/y denotes the set

a) {x,y}

b) {xy}

c) {x}

d) {y}

### View Answer

9. The regular expression denote a language comprising all possible strings of even length over the alphabet (0,1)

a) 1 + 0(1+0)*

b) (0+1)(1+0)*

c) (1+0)

d) (00+0111+10)*

### View Answer

10. The regular expressions denote zero or more instances of an x or y is

a) (x+y)

b) (x+y)*

c) (x* + y)

d) (xy)*