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

Correct Option - b

To get all Infosys Certified Java Programmer Exam questions Join Group https://bit.ly/infy_premium_group

We're passionate about offering best placement materials and courses!! A one stop place for Placement Materials. We daily post Offcampus updates and Placement Materials.

Qtr No. 213, New Town Yehlanka Indore 454775

admin@prepflix.in