Compilers Questions and Answers – Regular Expression – 1

This set of Compilers Multiple Choice Questions & Answers (MCQs) focuses on “Regular Expression – 1”.

1. A regular expression enables a quick test to determine objects and text strings with undependable values.
a) True
b) False
View Answer

Answer: a
Explanation: Because it checks for all the values and determines whether the output string matches with the given string.

2. RE can be used only for values of type string and number.
a) True
b) False
View Answer

Answer: b
Explanation: No not for all values the string and numbers can we use the RE.

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

Answer: b
Explanation: For every cycle the values does not change unpredictably because the type of grammar that it accepts is defined.
advertisement
advertisement

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

Answer: a
Explanation: The programmatic description is genuinely treated as regular expression.

5. If a ‘/’ is used before a character that has no special meaning, ‘/’ is ignored.
a) True
b) False
View Answer

Answer: a
Explanation: The backslash carries no significance and it is ignored.
Note: Join free Sanfoundry classes at Telegram or Youtube

6. The regular expression denotes 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

Answer: d
Explanation: Option 1 + 0(1+0)* → It does not consider even length criteria for the question.
Option (0+1) (1+0)* → It can so happen here that from the former bracket it takes 0 or 1 and takes null from the latter then it forms a string of odd length
Option (1+0) → It gives either 1 or 0.
Hence Option (00+0111+10)* is the 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

Answer: b
Explanation: Whether x or y is denoted by x+y and for zero or more instances it is denoted but (x+y)*.
advertisement

Sanfoundry Global Education & Learning Series – Compilers.

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

advertisement

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.