Regular Expressions and Finite Automata MCQs January 8, 2026December 13, 2024 by u930973931_answers 10 min Score: 0 Attempted: 0/10 Subscribe 1. Which of the following is true about regular expressions? (A) Regular expressions define a sequence of tokens (B) Regular expressions can only match numeric values (C) Regular expressions are used for syntax analysis (D) Regular expressions are used to describe patterns in strings 2. What is the purpose of a finite automaton in the context of lexical analysis? (A) To execute the program (B) To determine the meaning of a program (C) To parse the syntactic structure of the code (D) To recognize patterns specified by regular expressions 3. Which of the following symbols is used in regular expressions to represent “zero or more occurrences” of the preceding element? (A) * (B) + (C) ? (D) 4. What is the primary difference between a deterministic finite automaton (DFA) and a non-deterministic finite automaton (NFA)? (A) DFA can be used for syntax analysis, while NFA cannot (B) DFA has one possible transition for each symbol in the alphabet, while NFA can have multiple transitions for the same symbol (C) NFA is faster than DFA (D) DFA can accept more strings than NFA 5. Which of the following is a valid regular expression to match a string that starts with “a” and ends with “b”? (A) ^a.*b$ (B) a.b (C) a*b (D) a.b 6. In a regular expression, what does the symbol “+” represent? (A) One or more occurrences of the preceding element (B) Zero or more occurrences of the preceding element (C) A character set (D) Any single character 7. Which of the following statements is true about the relation between regular expressions and finite automata? (A) Both (A) and (B) (B) Every finite automaton can be converted into a regular expression (C) Regular expressions and finite automata are mutually exclusive concepts (D) Every regular expression can be converted into a finite automaton 8. Which of the following is NOT a valid regular expression? (A) [0-9][a-z]+ (B) [a-zA-Z0-9] (C) (a|b|c) (D) (ab|cd) 9. What is the main advantage of using a deterministic finite automaton (DFA) over a non-deterministic finite automaton (NFA)? (A) DFA is guaranteed to run in linear time (B) DFA is more difficult to implement (C) DFA always requires fewer computational resources (D) DFA has more states than an NFA 10. Which of the following best describes a regular language in terms of finite automata? (A) A language that has no finite representation (B) A language that requires a pushdown automaton for recognition (C) A language that requires a Turing machine for recognition (D) A language that can be recognized by a finite automaton