Array Loop Boundary Error
What is the flaw in the modifyArray method?
public class ArrayModification {
public static void modifyArray(int[] arr) {
for (int i = 0; i <= arr.length; i++) {
arr[i] *= 2;
}
}
}
A
The multiplication operation might cause integer overflow.
B
The array is modified without checking for null values.
C
The loop condition uses ‘<=’ instead of ‘<’, leading to an ArrayIndexOutOfBoundsException.
D
The method does not return the modified array.
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | bommasam000 | 3 | 3 | 1m 41s | 199 |
| #2 | hiboyshello | 1 | 1 | 0m 00s | 100 |
| #3 | upadhgau000 | 1 | 1 | 0m 00s | 100 |
| #4 | kazvin.tjakradinata | 1 | 1 | 0m 04s | 96 |
| #5 | singhris000 | 1 | 1 | 0m 07s | 93 |
| #6 | suhanakochhar006 | 1 | 1 | 0m 36s | 64 |
| #7 | midnightasdark | 1 | 2 | 0m 56s | 34 |
| #8 | theofanusmischa | 1 | 1 | 1m 22s | 18 |
| #9 | sathilak000 | 1 | 1 | 1m 57s | -17 |
| #10 | sailajavadlamani33 | 1 | 3 | 6m 05s | -285 |
Items per page:
10
1 – 10 of 12
APFIVE