Integer Object Comparison
What is printed as a result of executing the following code segment?
public static void compareObjects() {
Integer x = 127;
Integer y = 127;
Integer z = 128;
Integer w = 128;
String result = "";
if (x == y) {
result += "A";
}
if (x.equals(y)) {
result += "B";
}
if (z == w) {
result += "C";
}
if (z.equals(w)) {
result += "D";
}
System.out.println(result);
}
A
BD
B
ABCD
C
AB
D
ABD
Question Leaderboard
Not enough data yet to show leaderboard.
