Skip to content
Related Articles

Related Articles

Java | Arrays | Question 4
  • Difficulty Level : Basic
  • Last Updated : 09 Jan, 2014




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

(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

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :