Compiler Design MCQ Questions And Answers - Regular Expressions
This section focuses on "Regular Expressions" in Compiler Design. These Multiple Choice Questions (MCQ) should be practiced to improve the Compiler Design skills required for various interviews (campus interviews, walk-in interviews, company interviews), placements, entrance exams and other competitive examinations.
1. The grammar defined by regular expressions is known as?
A. regular language
B. regular grammar
C. regular notations
D. regular operation
View Answer
Ans : B
Explanation: The grammar defined by regular expressions is known as regular grammar
2. The language defined by regular grammar is known as?
A. regular language
B. regular grammar
C. regular notations
D. regular operation
View Answer
Ans : A
Explanation: The language defined by regular grammar is known as regular language.
3. Union of two languages L and M is written as?
A. LM = {st | s is in L and t is in M}
B. L+M
C. L*M
D. L U M = {s | s is in L or s is in M}
View Answer
Ans : D
Explanation: Union of two languages L and M is written as
L U M = {s | s is in L or s is in M}
4. Concatenation (.) has the ________ highest precedence
A. first
B. second
C. third
D. fourth
View Answer
Ans : B
Explanation: Concatenation (.) has the second highest precedence
5. Which of them are not left associative?
A. *
B. |
C. plus(+)
D. .
View Answer
Ans : C
Explanation: *, concatenation (.), and | (pipe sign) are left associative
6. 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
Ans : B
Explanation: The order for the desired string is 012 and for any number of 0s we write 0* for any number of 1s we denote it by 1* and similarly for 2*.Thus 0*1*2*.
7. 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
Ans : A
Explanation: ab followed by abb which is followed by bbab.
8. 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
Ans : A
Explanation: S->AA (substitute A->aa)
S->aaaa
S->AA (substitute A->aa )
S->aaA (substitute A->bb)
S->aabb
S->AA (substitute A->bb the A->aa)
S->bbaa
S->AA (substitute A->bb)
S->bbbb.
9. 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
Ans : D
Explanation: So says the definition of Regular Grammar
10. The non terminal that gives null will said to have a null production
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
View Answer
Ans : A
Explanation: True, The non terminal that gives null will said to have a null production.
Discussion