Java | Arrays | Question 4

filter_none

edit
close

play_arrow

link
brightness_4
code

class Test {
   public static void main(String args[]) {
     int arr[] = new int[2];  
     System.out.println(arr[0]);
     System.out.println(arr[1]);
   }
}

chevron_right


(A)

0
0

(B)

garbage value
garbage value

(C) Compiler Error
(D) Exception


Answer: (A)

Explanation: Java arrays are first class objects and all members of objects are initialized with default values like o, null.

Quiz of this Question



My Personal Notes arrow_drop_up


Article Tags :
Practice Tags :


1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.