✏️ Explanatory Question
int ar[] = {1, 2, 3, 4, 5}; int a = 1; for (int i = 0; i < 7; i++) { a = a + i * ar[i]; } System.out.println(a);
Array out-of-bounds issue:
The array ar has only 5 elements (ar[0] to ar[4]).
The loop runs from i = 0 to i = 6, which will attempt to access ar[5] and ar[6]. These indices are out of bounds, and the program will throw an ArrayIndexOutOfBoundsException at runtime.