Wrapper Classes: Integer and Double

AP Computer Science A· difficulty 3/5

String s = "42";
int n = Integer.parseInt(s);
System.out.println(n + 1);

What is printed?

  • A

    421

  • B

    42

  • C

    Error

  • D

    43

    check_circle

Explanation

Integer.parseInt converts the string "42" to the int 42; adding 1 gives 43.

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

Related questions