Predict the output of the following code snippet:
public class TestDemo {
public static void main(String[] args) {
try {
Marks(4);
Marks(3);
Marks(2);
Marks(1);
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Array index is out of bounds at main");
}
}
public static void Marks(int x) {
int marks[][] = {{10, 20}, {9, 12}, {8, 16}, {7, 15}};
int total[] = {0, 0, 0, 0};
try {
total[x] = (marks[x][0] + marks[x][1]);
System.out.println(total[x]);
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Array index is out of bounds at method");
}
}
}
Array index is out of bounds at method
Array index is out of bounds at method
22
24
21
Array index is out of bounds at main
22
24
21
Array index is out of bounds at main
To get all Infosys Certified Java Programmer Exam questions Join Telegram Group https://rebrand.ly/lex-telegram-236dee