Multiple choice technology programming languages

Consider this as a part of a code which has no compilation errors or runtime exceptions 21.Integer i1=1000; 22.Integer i2=1000; 23.System.out.println(i1==i2); what is the output?

  1. true

  2. false

  3. compilation fails at line 21

  4. compilation fails at line 22

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Integer values between -128 and 127 are cached by Java's Integer class, so i1 == i2 returns true for small values like 100 (same object reference). For values like 1000, outside the cached range, new Integer objects are created, so i1 and i2 reference different objects, making == return false. This tests understanding of Integer caching and reference vs value comparison.