Question 1
Back to Exercise
What is the output of the following Java program?
public class Main {
public static void main(String[] args) {
Integer a = 100, b = 100, c = 1000, d = 1000;
System.out.println((a == b) + " " + (c == d) + " " + c.equals(d) + " " + (c == 1000));
}
}
- A true false true true Correct
- B true true true true
- C false false true true
- D true false true false
Correct Answer: Option A
100 comes from the cache; 1000 does not. c == 1000 unboxes c and compares ints.
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!