Return to site
JAVA CERTIFICATION QUESTION: Declaring and initializing one-dimensional arrays in Java
·
There are several ways to create an array and initialize an array declaration.
Some can be used anywhere. Others can’t.
Which code will print 0 to console? Choose one.
A. int arr1[] = new int[10];
System.out.print(arr1[0]);
B. int arr2[10] = new int[10];
System.out.print(arr2[3]);
C. int[] arr3 = new int[0]{};
System.out.print(arr3.length);
D. int[] arr4 = {0,0};
System.out.print(arr4[arr4.length]);