Question 12
Back to Exercise
What is the output of the following Java program?
public class Main {
public static void main(String[] args) {
String s = "java";
s.toUpperCase();
s.concat(" rocks");
String t = s.replace('j', 'l');
System.out.println(s + " " + t);
}
}
- A java lava Correct
- B JAVA ROCKS lava
- C java rocks lava rocks
- D lava lava
Correct Answer: Option A
String methods return new strings; ignoring the result leaves s unchanged.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!