Autoboxing Unboxing

1.What is autoboxing in Java?
  • A. The automatic conversion of a primitive type to its corresponding wrapper class object.
  • B. The automatic conversion of a wrapper class object to its corresponding primitive type.
  • C. The manual conversion of a primitive type to a wrapper class object.
  • D. The manual conversion of a wrapper class object to a primitive type.

The automatic conversion of a primitive type to its corresponding wrapper class object.

The automatic conversion of a primitive type to its corresponding wrapper class object.

2.Which of the following scenarios demonstrates unboxing?
  • A. Integer obj = 10;
  • B. int i = new Integer(50);
  • C. String s = "hello";
  • D. double d = 3.14;

int i = new Integer(50);

int i = new Integer(50);

3.What potential issue can arise due to autoboxing/unboxing, particularly with null values?
  • A. StackOverflowError
  • B. NullPointerException
  • C. ArrayIndexOutOfBoundsException
  • D. ClassCastException

NullPointerException

NullPointerException

4.Which Java version introduced autoboxing and unboxing?
  • A. Java 1.0
  • B. Java 1.2
  • C. Java 5
  • D. Java 8

Java 5

Java 5

5.Considering the following code, what will be the output?
Integer i1 = 100; Integer i2 = 100; Integer i3 = 200; Integer i4 = 200; System.out.println(i1 == i2); System.out.println(i3 == i4);
  • A. true, true
  • B. true, false
  • C. false, true
  • D. false, false

true, false

true, false