Java OCA OCP Practice Question 891

Question

What is a possible output of the following code?

String[] strings = new String[2]; 
System.out.println(strings); 
A.   [null, null] 
B.   [,] 
C.   [Ljava.lang.String;@54a12183 
D.  None of the above 


C.

Note

Calling toString() on an array doesn't output the contents of the array, making Option C correct.

If you wanted Option A to be the answer, you'd have to call Arrays.toString(strings).




PreviousNext

Related