I declared an array as shown below:
int[] arr = new int[10];
Then I assigned following values to the array:
arr[0] = 1;
arr[1] = 2;
arr[2] = 3;
arr[3] = 4;
Then I declared and initialized an integer variable:
int arrayLength = arr.length;
Will arrayLength contain 10, the allocated size of the array or 4, the count of elements that have been explicitly assigned?
It contains the allocated size,
10. The unassigned indexes will contain the default value which is0forint.