Квиз по Java: 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 и серию.

Пример вопроса

Вопрос 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, серию, значки и историю.

Можно пройти ещё раз?

Да. Лучший результат сохраняется, а вопросы и ответы каждый раз перемешиваются.