23.5k views
0 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. 99
2. 100
3. 0
4. 101

User Berliner
by
5.7k points

1 Answer

3 votes

Answer:

Option 1 is the correct answer for the above question.

Step-by-step explanation:

If a user declares an array of n size then the starting index value of that array is 0 and the ending index value of that array is (n-1). This is the property of an array. In the question segment array is defined with the size of 100 then its starting index value is 0 and the ending index value is 99 (from the array property ).

Hence option 1 is right because the last index of the array is 99 with the help of array property which is described above while the other is not because--

  • Option 2 states that the index value of the last element of the array is 100 which neglects the property of an array.
  • Option 3 states that the index value of the last element of the array is 0 which neglects the property of an array.
  • Option 4 states that the index value of the last element of the array is 101 which neglects the property of an array.
User Kenniesha
by
5.7k points