Array Element Shifting With A For Loop
Which of the following represents the contents of arr as a result of executing the code segment?
Consider the following code segment.
int[] arr = {1, 2, 3, 4, 5, 6, 7};
for (int k = 3; k < arr.length - 1; k++)
arr[k] = arr[k + 1];
Which of the following represents the contents of arr as a result of executing the code segment?
A
{1, 2, 3, 5, 6, 7, 8}
B
{2, 3, 4, 5, 6, 7, 7}
C
{1, 2, 3, 5, 6, 7, 7}
D
{1, 2, 3, 4, 5, 6, 7}
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | vempaami000 | 1 | 1 | 0m 00s | 100 |
| #2 | kaisuki | 1 | 2 | 0m 00s | 90 |
| #3 | singh.advik13 | 1 | 2 | 1m 02s | 28 |
| #4 | singhris000 | 1 | 1 | 1m 40s | 0 |
| #5 | gizemsever68+tester | 0 | 1 | 0m 00s | -10 |
| #6 | y.seong2027 | 1 | 2 | 5m 25s | -235 |
| #7 | geethasailaja | 1 | 2 | 18m 36s | -1,026 |
APFIVE