Multiple choice technology programming languages

What is the output for the below code ?import java.util.regex.Matcher;import java.util.regex.Pattern;public class Test { public static void main(String... args) { Pattern p = Pattern.compile("a*b"); Matcher m = p.matcher("b"); boolean b = m.matches(); System.out.println(b); }}

  1. true

  2. Compile Error

  3. false

  4. b

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

The regex pattern a*b means zero or more 'a' characters followed by 'b'. The string b matches because it has zero 'a's (valid) followed by 'b'. The matches() method returns true when the entire input matches the pattern.