Menu
Question Index
...

What will be the output of the following program?

import java.util.regex.*;
public class Match {
    public static void main(String[] args) {
        Pattern p = Pattern.compile("(aa|a|aab?)+");
        int count = 0;
        for (String s = ""; s.length() < 200; s += "a")
            if (p.matcher(s).matches())
                count++;
        System.out.println(count);
    }
}


99
100
199
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Regular Expression

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App