What is the purpose of the `group()` method in Java regular expressions?
A. It compiles a regular expression
B. It checks if a string matches the pattern
C. It returns the matched subsequence
D. It counts the number of matches
Select an option to see the answer and solution.
In a regular expression, what does the metacharacter `w` represent?
A. Any special character
B. Any word character (letter, digit, or underscore)
C. Any lowercase letter
D. None of These
Select an option to see the answer and solution.
Which method is used to append replacement text in a Java regular expression operation?
A. `replaceText()`
B. `addReplacement()`
C. `appendReplacement()`
D. `appendText()`
Select an option to see the answer and solution.
In a regular expression, what does the metacharacter `b` represent?
A. A digit
B. Any character
C. Any special character
D. A word boundary
Select an option to see the answer and solution.
What is the purpose of the `quote()` method in Java regular expressions?
A. It returns a literal pattern string for the specified string
B. It quotes a matched subsequence
C. It compiles a regular expression
D. It checks if a string matches the pattern
Select an option to see the answer and solution.
In a regular expression, what does the metacharacter `Q` represent?
A. A digit
B. A word boundary
C. The end of a quoted section
D. The beginning of a quoted section
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?
A. `Group`
B. `Matcher`
C. `CharacterGroup`
D. `Pattern`
Select an option to see the answer and solution.
In a regular expression, what does the metacharacter `A` represent?
A. A word boundary
B. The beginning of a string
C. A digit
D. None of These
Select an option to see the answer and solution.
What is the purpose of the `reset()` method in Java regular expressions?
A. It counts the number of matches
B. It checks if a string matches the pattern
C. It resets the matcher
D. It compiles a regular expression
Select an option to see the answer and solution.
In a regular expression, what does the metacharacter `G` represent?
A. The start of the next match
B. A word boundary
C. A digit
D. The end of the previous match
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).
A. 3:55:4
B. 3.55.4
C. 55:03:04
D. 03:55:04
Select an option to see the answer and solution.
What does public int end(int group) return?
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
Select an option to see the answer and solution.
What is the significance of Matcher class for regular expression in java?
A. interpretes pattern in the string
B. Performs match in the string
C. interpreted both pattern and performs match operations in the string
D. None of the mentioned.
Select an option to see the answer and solution.
Which capturing group can represent the entire expression?
A. group *
B. group 0
C. group * or group 0
D. None of the mentioned
Select an option to see the answer and solution.
Which of the following matches end of the string using regular expression in java?
A. \z
B. \\
C. \*
D. None of These
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?
A. Pattern class
B. matcher class
C. PatternSyntaxException
D. Regex class
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).
A. Mon Jul 15 2013
B. Jul 15 2013
C. 55:03:04 Mon Jul 15 2013
D. 03:55:04 Jul 15 2013
Select an option to see the answer and solution.
What does public int start() return?
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
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.