Home / CSE MCQs / Java Regex ::

CSE MCQs :: Java Regex

  1. What is the significance of Matcher class for regular expression in java?
  2. A.
    interpretes pattern in the string
    B.
    Performs match in the string
    C.
    interpretest both pattern and performs match operations in the string
    D.
    None of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. Which capturing group can represent the entire expression?
  4. A.
    group *
    B.
    group 0
    C.
    group * or group 0
    D.
    None of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. What does public int end(int group) return?
  6. A.
    offset from last character of the subsequent group
    B.
    offset from first character of the subsequent group
    C.
    offset from last character matched
    D.
    offset from first character matched

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. Which of the following identity is wrong?
  8. A.
    R + R = R
    B.
    (R*)* = R*
    C.
    Both A and B
    D.
    (phi)R = R(phi) = RR*

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. Which of the following is not a class of java.util.regex?
  10. A.
    Pattern class
    B.
    matcher class
    C.
    PatternSyntaxException
    D.
    Regex class

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. Regular expressions are used to represent which language
  12. A.
    Recursive language
    B.
    Context free language
    C.
    Regular language
    D.
    All of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. The set of all strings over Sigma = {a,b} in which all strings having bbbb as substring is
  14. A.
    (a+b)* bbbb (a+b)*
    B.
    (a+b)* bb (a+b)*bb
    C.
    bbbb (a+b)*
    D.
    bb (a+b)*

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. What does public int start() return?
  16. A.
    returns start index of the input string
    B.
    returns start index of the current match
    C.
    returns start index of the previous match
    D.
    none of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. Which of the following statements about the regex API are true?
  18. A.
    Instances of the Pattern class are used to match character sequences against a given pattern
    B.
    The package java.util.regex includes an exception called PatternSyntaxException
    C.
    Instances of Matcher class are used to represent regular expressions in the form of String type
    D.
    None of the above

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. What are the main methods of Java Regex?
  20. A.
    matches
    B.
    lookingAt
    C.
    find
    D.
    All of the above

    View Answer

    Workspace

    Discuss Discuss in Forum