96.6k views
2 votes
Perform the following tasks for an array called tests.

Declare and create the array as an integer array that has three rows and three columns.

Assume the the constant ARRAY_SIZE has been declared to 3.

1 Answer

6 votes

Final answer:

To declare and create an integer array called tests with three rows and three columns, use the code int[ ][ ] tests = new int[3][3].

Step-by-step explanation:

In computer science, an array is a data structure consisting of a collection of elements, of same memory size, each identified by at least one array index or key.

An array is stored such that the position of each element can be computed from its index tuple by a mathematical formula. To declare and create an integer array called tests with three rows and three columns, you can use the following code:

int[][] tests = new int[3][3];

This creates a 2-dimensional array with dimensions 3x3. Each element in the array can hold an integer value.

You can then access and manipulate individual elements in the array using their respective row and column indices.

Arrays are "lists" of related values. Every value in the array is usually of the exact same type and only differentiated by the position in the array.

For example, all the quiz scores for a test could be stored in an array with the single variable name: quiz_scores.

User Dante Cullari
by
7.9k points