Given the following 2D array:


int[][] matrix = {
    {5, 8, 3},
    {4, 9, 7},
    {6, 2, 1}
};

Write a program to display the element at the second row, third column.

Single Choice
Views 36

Answer:


public class Main {
    public static void main(String[] args) {
        int[][] matrix = {
            {5, 8, 3},
            {4, 9, 7},
            {6, 2, 1}
        };
        
        System.out.println("Element at 2nd row, 3rd column: " + matrix[1][2]);
    }
}

Related Articles:

This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Java Programming Language, click the links and dive deeper into this subject.

Join Our telegram group to ask Questions

Click below button to join our groups.