16.5k views
5 votes
int[] num = new int[100];for (int i = 0; i < 50; i++)num[i] = i;num[5] = 10;num[55] = 100;What is the index number of the last component in the array above?1. 992. 1003. 04. 101

User Bibby
by
8.8k points

1 Answer

2 votes

Answer:

1. 99

Step-by-step explanation:

As the array is declared with space of 100 integers, 100 integers' space will be allocated to variable num. Moreover, Index number of last component is always the length - 1 because array's index start with 0 and ends till length-1. As array will initialize all the remaining spaces with garbage value so they will be displayed if accessed through num[index] where index s the index number to be displayed.

As size of array is 100. So, 99 will be the index of the last component of the array.

User Jeremy Evans
by
8.1k points