JAVA Programming :: Basic Concepts - Discussion
Home > JAVA Programming > Basic Concepts > MCQs Questions Discussion
8 / 64
Choose the correct option.
class ArrayTest {
public static void main(String[] args) {
int[][] a1 = {{1,2,3},{4,5,6},{7,8,9,10}};
System.out.print(a1[0][2]+","+a1[1][0]+","+a1[2][1]);
}
}
class ArrayTest {
public static void main(String[] args) {
int[][] a1 = {{1,2,3},{4,5,6},{7,8,9,10}};
System.out.print(a1[0][2]+","+a1[1][0]+","+a1[2][1]);
}
}
APrints: 3, 4, 8
BPrints: 7, 2, 6
CRun-time error
DCompile-time error
Answer: Option (Login/Signup)
Show Explanation
a1[0][2] = element in the first row and third column = 3
a1[1][0] = element in the second row and first column = 4
a1[2][1] = element in the third row and second column = 8
Hence, it prints 3,4,8.
Asked In ::
STEP-BY-STEP
In the given 2-dimensional array a1-
a1[0][2] = element in the first row and third column = 3
a1[1][0] = element in the second row and first column = 4
a1[2][1] = element in the third row and second column = 8
Hence, it prints 3,4,8.
Read Full Answer
Report Error
Please Login First Click Here