88.9k views
5 votes
Consider the following statements:

int[ ] p = new int[100];
int[ ] s = p;
Which of the following statements will change the last value of p to 75? (There may be more than one correct answer.)
p[99] = 75; p[100] = 75; s[99] = 75; s[100] = 75;

1 Answer

1 vote

Final answer:

The correct statement that will change the last value of p to 75 is p[99] = 75. This is because arrays are zero-indexed.

Step-by-step explanation:

The correct statement that will change the last value of p to 75 is p[99] = 75. This is because arrays are zero-indexed, so p[99] refers to the last element in the array. The other statements, p[100] = 75, s[99] = 75, and s[100] = 75, would result in errors or out-of-bounds access.

User Kgm
by
8.5k points