Site icon DataFlair

Quiz on Java Regular Expression

quiz on java regular expression

Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java

Unleash the hidden potential within Java strings! Regular expressions, often abbreviated as regex, are powerful tools that unlock the ability to manipulate and decipher text with incredible precision. Mastering regex empowers you to search for specific patterns within strings, extract valuable data, and even replace unwanted elements.

This interactive quiz is designed to be your personal training ground for regex mastery. By tackling real-world scenarios presented in the quiz, you’ll have the opportunity to apply your existing regex knowledge and identify areas where you can further refine your skills.

Whether you’re a seasoned Java developer well-versed in the intricacies of code, or just embarking on your programming journey, this quiz serves as your gateway to becoming a regex pro. So, are you ready to unlock the true power of text manipulation in Java? Take the quiz, challenge yourself, and watch your regex skills soar! Let’s test your knowledge.

Time limit: 0

Quiz Summary

0 of 15 Questions completed

Questions:

Information

You have already completed the quiz before. Hence you can not start it again.

Quiz is loading…

You must sign in or sign up to start the quiz.

You must first complete the following:

Results

Quiz complete. Results are being recorded.

Results

0 of 15 Questions answered correctly

Your time:

Time has elapsed

You have reached 0 of 0 point(s), (0)

Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)

Categories

  1. Not categorized 0%
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  1. Current
  2. Review / Skip
  3. Answered
  4. Correct
  5. Incorrect
  1. Question 1 of 15
    1. Question

    class RegularExpressions {

    public static void main ( String args [ ] )

    {

    Pattern p = Pattern.compile(“..s”); 

    Matcher m = p.matcher(“was”);  

    boolean b = m.matches(); 

    system.out.println(b); 

    }

    }

    Correct
    Incorrect
  2. Question 2 of 15
    2. Question

    class RegExp {

    public static void main ( String args [ ] )

    {

    boolean b = Pattern.compile(“..d”).matcher(“adsense”).matches();

    system.out.println(b);

    }

    }

    Correct
    Incorrect
  3. Question 3 of 15
    3. Question

    Which of the following is not a syntax to find the strings are equal to each other ?

    Correct
    Incorrect
  4. Question 4 of 15
    4. Question

     class Sample {

    public static void main ( String args [ ] )

    {

        System.out.println(Pattern.matches(“[a-d[m-p]]”, “DataFlair”));  

        }

    }

    Correct
    Incorrect
  5. Question 5 of 15
    5. Question

    class RegExpression {

    public static void main ( String args [ ] )

    {

    boolean b = Pattern.matches(“[d]?”, “DataFlair”);  

    if(b == true )

    {

    system.out.println(“D is present only once in the word DataFlair”);

    } else {

    system.out.println(“D is present more than once in the word DataFlair”);

    }

    }

    }

    Correct
    Incorrect
  6. Question 6 of 15
    6. Question

    Which of the following programs perform a search operation for whether the given character is present n times in the given input string ?

    Correct
    Incorrect
  7. Question 7 of 15
    7. Question

    class RegexCharacterClass {

    public static void main ( String args [ ] )

    {

    boolean b = Pattern.matches(“[^xyz]”, “DataFlair”);  

    system.out.println(b + “DataFlair”);

    }

    }

    Correct
    Incorrect
  8. Question 8 of 15
    8. Question

    class Exception {

    public static void main ( String args [ ] )

    {

    boolean b = Pattern.matches( “DataFlair”); 

    system.out.println(b);

    }

    Correct
    Incorrect
  9. Question 9 of 15
    9. Question

    class RegExpressionExample {

    public static void main ( String args [ ] )

    {

    Scanner sc = new Scanner(System.in);

    char Input = sc.nextChar();

    System.out.println( Pattern.matches(“\\D+”, “Input”));  

    }

    }

    Correct
    Incorrect
  10. Question 10 of 15
    10. Question
    1. Which matcher class in Regular expression is used to find the next expression that matches the given pattern  from the given first Number ?

    Correct
    Incorrect
  11. Question 11 of 15
    11. Question

    class Example {

    public static void main ( String args [ ] )

    {

    boolean b = Pattern.matches(“[a]{3,5}”, “DataFlair”));

    System.out.println(b);

    }

    }

    Correct
    Incorrect
  12. Question 12 of 15
    12. Question

    What should be the argument passed to the class static boolean matches ( ) to get the respected output ?

    Correct
    Incorrect
  13. Question 13 of 15
    13. Question

    Which of the following programs is used to search a string for a non-word character ?

    Correct
    Incorrect
  14. Question 14 of 15
    14. Question

    What will be the output of the Static pattern compile ( String regex) class in Java ?

    Correct
    Incorrect
  15. Question 15 of 15
    15. Question

    class Regular {

    public static void main ( String args [ ] )

    {

    boolean b = Pattern.matches(“[X]+” , “input string”);

    system.out.println(b);

    }

    }

    Correct
    Incorrect

Summary:

Regular expressions, or regex for short, are powerful tools in any Java developer’s arsenal. They allow you to wield the magic of pattern matching, sifting through mountains of text data with pinpoint accuracy. Whether you’re a seasoned regex warrior or just starting to explore this fascinating realm, this quiz is designed to be your ultimate training ground.

Dive deep into a series of interactive challenges that will test your ability to craft complex patterns, pinpoint specific text elements, and extract valuable data from seemingly chaotic strings.

This is no ordinary quiz; it’s an immersive learning experience designed to not only assess your current understanding but also push your boundaries and unlock the full potential of regex in your Java programming.

So, are you ready to put your skills to the test? Embrace the challenge, conquer each question, and watch your regex mastery blossom. You’ll emerge from this experience not just with a clearer understanding of your strengths and weaknesses, but also with the confidence to tackle any text manipulation task Java throws your way!

Exit mobile version