Computer Applications

What do you understand by two-dimensional arrays ? State some situations that can be easily represented by two-dimensional arrays.

Java Arrays

2 Likes

Answer

A two-dimensional array is an array in which each element is itself an array. For instance, an array A[M][N] is an M by N table with M rows and N columns containing M x N elements.

The general form of a two-dimensional array declaration in Java is as follows:
type array-name[ ][ ] = new type[rows][columns];

Some situations that can be easily represented by two-dimensional arrays are as follows:

  1. In a school, marks obtained by a student in various subjects can be stored in a two-dimensional array, where rows can be used for successive tests (mid term, quarterly, half yearly etc.) and columns can be used for subjects (maths, english, science, hindi, computer etc.).
  2. In a business, the sales for a month can easily be represented using a two-dimensional array, where rows can represent weeks and columns can represent the individual days in a week.

Answered By

1 Like


Related Questions