String Modification Attempt
A method attempts to modify a String parameter, demonstrating pass-by-value behavior.
What is printed when the following Java program is compiled and run?
public class QuestionTrace {
public static void modify(String s) {
s = s + "!";
}
public static void main(String[] args) {
String s = "A";
modify(s);
System.out.print(s);
}
}
A
A!
B
error
C
null
D
A
Question Leaderboard
Not enough data yet to show leaderboard.
