Question
Option 1 : true false
Detailed Solution
सही उत्तर true false है।
Question:
What is the output of the following Java code? Integer a = 127, b = 127; Integer c = 128, d = 128; System.out.println((a==b) + " " + (c==d)); / निम्नलिखित Java कोड का आउटपुट क्या है? Integer a = 127, b = 127; Integer c = 128, d = 128; System.out.println((a==b) + " " + (c==d));
Correct Answer: true false
The == operator compares object references. Java caches Integer objects in the range -128 to 127, so a and b refer to the same cached object (true), while 128 is outside the cache, so c and d are distinct objects (false). / == ऑपरेटर ऑब्जेक्ट संदर्भों की तुलना करता है। Java -128 से 127 रेंज के Integer ऑब्जेक्ट कैश करता है, अतः a और b एक ही कैश्ड ऑब्जेक्ट को संदर्भित करते हैं (true), जबकि 128 कैश के बाहर है, अतः c और d भिन्न ऑब्जेक्ट हैं (false)।