136k views
5 votes
Given the following code:

int [ ] numList = new int [50];
for (int i = 0; i < 50; i++) numList [i] = 2 * i;
num[10] = -20;
num[30] = 8;
What is the value of numList.length in the array above?

User PPS
by
8.3k points

1 Answer

6 votes

Final answer:

The value of numList.length in the given code is 50, as the array is initialized to hold 50 elements.

Step-by-step explanation:

The value of numList.length in the array is the total number of elements it can hold. In the provided code, numList is initialized with a size of 50, so regardless of the value of each element, the length of the array remains 50.

This is a fixed property of the array once it is created and does not change even if individual elements of the array are modified, such as numList[10] being set to -20 and numList[30] to 8.

User Gallagher
by
7.6k points