Wrapper Classes: Integer and Double

AP Computer Science A· difficulty 3/5

int n = 5;
Integer w = n;
System.out.println(w + 1);

What is printed?

  • A

    6

    check_circle
  • B

    5

  • C

    51

  • D

    Error

Explanation

The int 5 is autoboxed into Integer w, then unboxed for arithmetic; the result is 6.

Want 10 more like this — adaptive to your weak spots?

Related questions