Compilers Questions and Answers – Finite Automata and Regular Expressions – 2

This set of Compilers Interview Questions and Answers focuses on “Finite Automata and Regular Expressions – 2”.

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

            
 S → SaSbS|ε 

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

Answer: d
Explanation: 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
View Answer

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

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

Answer: c
Explanation: 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
View Answer

Answer: a
Explanation: It is seen that programmatic description are treated as regular expression.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

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

Answer: a
Explanation: 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
View Answer

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

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}
View Answer

Answer: b
Explanation: 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}
View Answer

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

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)*
View Answer

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

Sanfoundry Global Education & Learning Series – Compilers.

To practice all areas of Compilers for Interviews, here is complete set of 1000+ Multiple Choice Questions and Answers.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.