Question
Consider the following Java code: import
java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexGroup { Â Â public static void main(String[] args) { Â Â Â Â String text = "Date: 2023-10-26, Time: 14:30"; Â Â Â Â Pattern pattern = Pattern.compile("(\\d{4})-(\\d{2})-(\\d{2})"); Â Â Â Â Matcher matcher = pattern.matcher(text); Â Â Â Â if (matcher.find()) { Â Â Â Â Â Â System.out.println(matcher.group(0) + " | " + matcher.group(1)); Â Â Â Â } else { Â Â Â Â Â Â System.out.println("No match"); Â Â Â Â } Â Â } } What will be the output of this program?Solution
Correct Answer: A (matcher.group(0) returns the entire matched string. matcher.group(1) returns the content of the first capturing group, which is (\d{4}).)
Hariom has 85 notes of Rs 50 and Rs 100. If the total money he has is Rs 5000, then find the number of Rs 50 notes.
- The ratio of apples to oranges in a basket is 3:2. If 12 apples are removed and 18 oranges are added, then the number of apples and oranges becomes equal. ...
In a transport yard, 70% of the vehicles are two-wheelers and the rest are four-wheelers. Find the ratio of the number of wheels of two-wheelers to that...
- In a company of 720 employees, the ratio of men to women is 5:4. Among men, the ratio of married to unmarried men is 3:2. Among women, the ratio of married...
Number of faculties in Physics and Biology in an institute is in the ratio of 2:3 respectively. If 60 more faculties join Physics, while 32 more faculti...
The ratio of the monthly expenditure to monthly income is 4:5. If the salary increased by Rs. 4550 such that ratio of old saving and new saving is 2:3, ...
- Find the mean proportion of 7.2 and 16.2.
Two friends, A and B, have money in the ratio of 4:3. If A's money decreases by 20% and B's money increases by Rs 35, their amounts become equal. What i...
<p><p>Sides of a parallelogram are in the ratio 6:5. Its area is 2700 sq. units. Altitude on the greater side is 30 units. Altitude ...
A starts a business with Rs. 6600. After 3 months, B joins with A as his partner. After one year the profit is divided in the ratio 4:5. What is B&r...