Multiple choice technology programming languages

Given: import java.util.regex.; class Regex2 { public static void main(String[] args) { Pattern p = Pattern.compile(args[o]); Matcher m = p.matcher(args[1]); boolean b = false; while(b = m.find()) { System.out.print(m.start() + m.group()); } } } And the command line: java Regex2 "\d" ab34ef What is the result?

  1. 234

  2. 334

  3. 2334

  4. 0123456

  5. 01234456

  6. 12334567

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

The regex \d* matches zero or more digits, finding matches at positions 0, 1, 2, 3, 4, 5, 6. The output format shows position+group, giving: 0 + '' (empty match at start), 1 + '' (between a and b), 2 + '' (between b and 3), 3 + 3, 4 + '' (between 3 and 4), 5 + 4, 6 + '' (between 4 and e). This produces 01234456. Option E is correct.