Menu
Question Index
...

What will be the output of the following program?

public class Replace {

    public static void main(String a[]) {
        String replaceStr = "<B>Good Day<\\B>";
        System.out.println("Before replace: " + replaceStr);
        replaceStr = replaceStr.replaceAll("\\<.*?\\>", "");
        System.out.println("After replace: " + replaceStr);
    }
}


Before replace: <B>Good Day<\B>
After replace: Good Day
Before replace: <B>Good Day<\B>
After replace:
Before replace: <B>Good Day<\B>
After replace: <B>Good Day<\B>
Before replace: <B>Good Day<\B>
After replace: BGood Day\B
Compilation Error or Runtime Error

Doubts

Problems

Topic: Additional String Methods in Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App