Vidyalelo
Java Programming · all questions

Java Regular Expressions
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

50

Questions

2/3

Page

Pick an option on a question to see the right answer and solution.

What is the purpose of the `group()` method in Java regular expressions?

Select an option to see the answer and solution.

In a regular expression, what does the metacharacter `w` represent?

Select an option to see the answer and solution.

Which method is used to append replacement text in a Java regular expression operation?

Select an option to see the answer and solution.

In a regular expression, what does the metacharacter `b` represent?

Select an option to see the answer and solution.

What is the purpose of the `quote()` method in Java regular expressions?

Select an option to see the answer and solution.

In a regular expression, what does the metacharacter `Q` represent?

Select an option to see the answer and solution.

Which class is used to represent a group of characters in a regular expression in Java?

Select an option to see the answer and solution.

In a regular expression, what does the metacharacter `A` represent?

Select an option to see the answer and solution.

What is the purpose of the `reset()` method in Java regular expressions?

Select an option to see the answer and solution.

In a regular expression, what does the metacharacter `G` represent?

Select an option to see the answer and solution.

What will be the output of the following Java program?
import java.text.*;
import java.util.*;
class Date_formatting
{	 
    public static void main(String args[])
    {
  Date date = new Date();
  SimpleDateFormat sdf;
        sdf = new SimpleDateFormat("hh:mm:ss");
        System.out.print(sdf.format(date));
    }	
}

Note : The program is executed at 3 hour 55 minutes and 4 sec (24 hours time).

Select an option to see the answer and solution.

What does public int end(int group) return?

Select an option to see the answer and solution.

What is the significance of Matcher class for regular expression in java?

Select an option to see the answer and solution.

Which capturing group can represent the entire expression?

Select an option to see the answer and solution.

Which of the following matches end of the string using regular expression in java?

Select an option to see the answer and solution.

Which of these formatting strings of SimpleDateFormat class is used to print AM or PM in time?

Select an option to see the answer and solution.

Which of the following is not a class of java.util.regex?

Select an option to see the answer and solution.

What will be the output of the following Java program?
import java.text.*;
import java.util.*;
class Date_formatting
{	 
    public static void main(String args[])
    {
  Date date = new Date();
  SimpleDateFormat sdf;
        sdf = new SimpleDateFormat("E MMM dd yyyy");
        System.out.print(sdf.format(date));
    }	
}

Note: The program is executed at 3 hour 55 minutes and 4 sec on Monday, 15 July(24 hours time).

Select an option to see the answer and solution.

What does public int start() return?

Select an option to see the answer and solution.

groupCount reports a total number of Capturing groups.

Select an option to see the answer and solution.