Bird
0
0

What is the output of the following Java code?

medium📝 Predict Output Q4 of 15
Java - Arrays
What is the output of the following Java code?
int[][] arr = {{1, 2, 3}, {4, 5, 6}};
System.out.println(arr[1][0]);
A1
B4
C5
D6
Step-by-Step Solution
Solution:
  1. Step 1: Identify the element at arr[1][0]

    arr[1] is the second row: {4, 5, 6}. The element at index 0 is 4.
  2. Step 2: Print the value

    System.out.println prints 4.
  3. Final Answer:

    4 -> Option B
  4. Quick Check:

    arr[1][0] = 4 [OK]
Quick Trick: Remember zero-based indexing for rows and columns [OK]
Common Mistakes:
  • Confusing row and column indexes
  • Printing wrong element
  • Off-by-one errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes