Array Creation and Access

AP Computer Science A· difficulty 3/5

String[] s = new String[3];
System.out.println(s[0]);

What is printed?

  • A

    NullPointerException

  • B

    0

  • C

    (empty string)

  • D

    null

    check_circle

Explanation

For arrays of object references, the default initial value is null. Printing a null reference outputs the string "null".

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

Related questions