Menu
Question Index
...

What will be the output of the following program?

public class ReplaceCharacters
{
    public static void main(String args[])
    {
        String str = "Hello Java program.";

        System.out.println(str.replace('H', 'W'));
        System.out.println(str.replaceFirst("He", "Wa"));
        System.out.println(str.replaceAll("He", "Ha"));
    }
}


Wello Java program.
Wello Java program.
Wello Java program.
Wello Java program.
Wallo Java program.
Hallo Java program.
Wello Java program.
Hello Java program.
Hallo Java program.
Compilation Error
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