Question

1.
2.
3.
4.
Answer (Detailed Solution Below)

Option 2 : true false

Advertisement

Detailed Solution

सही उत्तर true false है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

Consider the Java fragment: Integer x = 127; Integer y = 127; Integer m = 128; Integer n = 128; System.out.print((x == y) + " " + (m == n)); What is printed? / Java कोड खंड पर विचार करें: Integer x = 127; Integer y = 127; Integer m = 128; Integer n = 128; System.out.print((x == y) + " " + (m == n)); क्या मुद्रित होगा?

1.
true true
2.
true false
3.
false true
4.
false false

Correct Answer: true false

Autoboxing caches Integer objects from -128 to 127, so x and y share one object (true), while 128 lies outside the cache and m, n are distinct objects (false). / ऑटोबॉक्सिंग -128 से 127 तक Integer ऑब्जेक्ट कैश करता है, अतः x और y एक ही ऑब्जेक्ट साझा करते हैं (true), जबकि 128 कैश से बाहर है और m, n भिन्न ऑब्जेक्ट हैं (false)।

Downloaded from PrepSnap (prepsnap.in)