String[] names = new String[3];
System.out.println(names[0].length());What happens when this code runs?
- Acheck_circle
NullPointerException because names[0] is null
- B
Prints 0
- C
Prints empty string
- D
Compile error
Explanation
A new String[] is filled with null references. Calling .length() on null throws NullPointerException.