Menu
Question Index
...

What will be the output of the following program?

public class Names {
    public static void main(String[] args) {
        String Str = new String("Welcome to meritcampus.com");
        Str += " give the correct option to win the dose";
        System.out.println(Str.replaceAll("(\\w)(\\s+)([\\.,])", ""));
        Str += "Hai Hello";
        System.out.println(Str.replace("[a-zA-Z]", ""));
    }
}


Welcome to meritcampus.com give the correct option to win the dose
Hai Hello
Welcometomeritcampuscomgivethecorrectoptiontowinthedose
Welcome to meritcampus.com give the correct option to win the dose
Welcome to meritcampus.com give the correct option to win the doseHai Hello
Welcometomeritcampuscomgivethecorrectoptiontowinthedose
WelcometomeritcampuscomgivethecorrectoptiontowinthedoseHai Hello
Some other output
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