250+ TOP MCQs on Finite Automata and Regular Expressions

Compilers Interview Questions and Answers on “Finite Automata and Regular Expressions”.

1. Which of the following strings is not generated by the following grammar?

            
 S → SaSbS|ε

a) aabb
b) abab
c) aababb
d) aaabbb

Answer: d
Clarification: Given S → SaSbS|ε
S->aSbS putting S-> € and then S->SaSbS
S->aSaSaSbSbSbS putting S->SaSbS
S->aaabbb putting S->€.

2. Regular expressions can be used only for values of type string and number.
a) True
b) False

Answer: b
Clarification: RE is used for all types of string and numbers.

3. What is the Regular Expression Matching Zero or More Specific Characters?
a) x
b) #
c) *
d) &

Answer: c
Clarification: Zero or Specific Expression matching can be done only by a single character that is*.

4. All __________ are automatically treated as regular expressions.
a) Programmatic description
b) Window
c) Win Object
d) Collection

Answer: a
Clarification: It is seen that programmatic description are treated as regular expression.

5. Regular Expressions can be used with XML checkpoints.
a) True
b) False

Answer: a
Clarification: XML checkpoints employ RE.

6. The production Grammar is {S->aSbb,S->abb} is __________ grammar.
a) Type-3
b) Type-2
c) Type-1
d) Type-0

Answer: b
Clarification: As per the definition of type-2 grammar.

7. Regular expression (x/y)(x/y) denotes which of the following set?
a) {xy,xy}
b) {xx,xy,yx,yy}
c) {x,y}
d) {x,y,xy}

Answer: b
Clarification: From first part if we take x then from the latter part x then it forms xx
From first part if we take x then from the latter part y then it forms xy
From first part if we take y then from the latter part x then it forms yx
From first part if we take y then from the latter part y then it forms yy.

8. Regular expression x/y denotes which of the following set?
a) {x,y}
b) {xy}
c) {x}
d) {y}

Answer: a
Clarification: Because either x or y can be selected.

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

Answer: b
Clarification: For instances of x or y the exp is x+y and both can zero or more times than (x+y)*.

Leave a Reply

Your email address will not be published. Required fields are marked *