Multiple choice technology programming languages

What will happen if you try to compile and run the following code? public class Q { public static void main(String argv[]){ int anar[]=new int[5]; System.out.println(anar[0]); } }

  1. Error: anar is referenced before it is initialized

  2. null

  3. 0

  4. 5

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

In Java, when you create a new int array, all elements are automatically initialized to 0. The code creates an int array of size 5 and prints the first element anar[0], which will be 0.