Java Quiz: Autoboxing & Wrapper Classes

This hard Java quiz is about wrapper classes like Integer and Long and the automatic boxing between them and primitives. It covers the classic interview gotchas: the Integer cache from -128 to 127, NullPointerException from unboxing, equals() across types and List.remove() with ints.

कठिन 10 सवाल ~8 मिनट पास होने के लिए 80% Java 17

मोड चुनें

आप गेस्ट के तौर पर खेल रहे हैं: XP और streak सेव रखने के लिए साइन इन करें।

सैंपल सवाल

सवाल 1 / 10

What does this print?

public class Main {
    public static void main(String[] args) {
        Integer a = 127, b = 127;
        Integer c = 128, d = 128;
        System.out.println((a == b) + " " + (c == d));
    }
}
जवाब दिखाएं

B. true false Autoboxing calls Integer.valueOf(), which returns cached objects for -128 to 127, so a and b are the same object. 128 is outside the cache, so c and d are different objects and == is false.

इस क्विज़ में क्या है

  • The Integer cache and == on wrappers
  • Unboxing null and the ternary trap
  • equals() between Long and Integer
  • list.remove(int) vs list.remove(Object)
  • Wrapper keys in maps

अक्सर पूछे जाने वाले सवाल

क्या अकाउंट ज़रूरी है?

नहीं। कोई भी खेल सकता है। XP, streak, badge और हिस्ट्री सेव रखने के लिए साइन इन करें।

क्या मैं इसे दोबारा दे सकता हूं?

हां। आपका बेस्ट स्कोर सेव रहता है, और हर बार सवाल और जवाब शफ़ल होते हैं।