Menu
Question Index
...

What will be the output of the following program?

public class Created {
    static String lines = "Hai now you are answering a dose which is created.\r\nBy MeritCampus.";
    public static void main(String[] args) {
        String sp[] = lines.split(" ");
        lines = "";
        for (String element : sp) {
            if (!element.equalsIgnoreCase("a")) {
                element.replace("a", "");
                System.out.print(element + " ");
                lines += " " + element;
            }
        }
        System.out.println("\n" + sysout());
    }
    static String str = lines;
    private static String sysout() {
        return toString(str);
    }
    public static String toString(String str) {
        return str;
    }
}


Hi now you re nswering dose which is creted.
By MeritCmpus.
Hai now you are answering a dose which is created.
By MeritCampus.
Hai now you are answering dose which is created.
By MeritCampus.
Hai now you are answering a dose which is created.
By MeritCampus.
Hai now you are answering a dose which is created.
By MeritCampus.
Hai now you are answering a dose which is created.
By MeritCampus.
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