Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardJavaInteger caching identitySingle-choice MCQ

Autoboxing in a == comparison uses Integer.valueOf, but the IntegerCache upper bound is configurable. Given the JVM flag -XX:AutoBoxCacheMax=1000, what does this snippet print and why?

Integer x = 500; Integer y = 500; Integer p = 1500; Integer q = 1500; System.out.println((x == y) + " " + (p == q));