What is the result?

public class StringReplace {
public static void main(String[] args) {
String message = “Hi everyone!”;
System.out.println(“message = ” + message.replace(“e”, “X”)); }
}
What is the result?

public class StringReplace {
public static void main(String[] args) {
String message = “Hi everyone!”;
System.out.println(“message = ” + message.replace(“e”, “X”)); }
}
What is the result?

A.
message = Hi everyone!

B.
message = Hi XvXryonX!

C.
A compile time error is produced.

D.
A runtime error is produced.

E.
message =

F.
message = Hi Xveryone!



Leave a Reply 3

Your email address will not be published. Required fields are marked *


ARJIT GAUTAM

ARJIT GAUTAM

B is wrong , C is correct !! compilation failure will occur..
the method replace() takes the argument as character type i.e in single quotes not in double quotes.

Stewe

Stewe

@ARJIT GAUTAM
Both, single quote and double quote will work!