48.1k views
4 votes
Consider the program segment below.

double grades[ ];
grades = new double[50];
What is the index range capable of accessing an element of the grades array?
(A) 0..49
(B) 1..49
(C) 0..50
(D) 1..50

User Frischling
by
8.0k points

1 Answer

7 votes

Final answer:

The index range for accessing elements of the 'grades' array in the program segment is 0 to 49, with the index starting at 0 for the first element and ending at 49 for the last element.

Step-by-step explanation:

The index range capable of accessing an element of the grades array is (A) 0..49. In the program segment provided, grades = new double[50]; declares an array of double variables with 50 elements. Since array indexing in Java starts at 0, the first element has an index of 0 and the last element has an index of the size of the array minus one, which in this case is 49.

User DSblizzard
by
7.0k points