Search Header Logo

2D Arrays

Authored by Alicia McNett

Computers

University

Used 3+ times

2D Arrays
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

5 questions

Show all answers

1.

FILL IN THE BLANK QUESTION

1 min • 1 pt

Complete this code for a 2D array: int[][] temps = ___ int[5][2];

2.

FILL IN THE BLANK QUESTION

1 min • 1 pt

Complete this for loop code to loop until the end of an array called "grades":

for(int row = 0; row < ___ ; row++) ...

3.

FILL IN THE BLANK QUESTION

1 min • 1 pt

What is missing below order to declare the array as a 3D array:

int[][]___ multiArray;

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In 2D arrays, each row must be the same length (e.g. 2D arrays cannot be ragged/jagged).

True

False

Answer explanation

In a 2D array, each row contains an array that consists of the columns. There is nothing stopping a 2D array from having rows of different sizes.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What value prints below?

int[][] vals = { { 1, 2 }, { 3, 4 } };

 

        System.out.println(vals[0][1]);

1

2

3

4

Answer explanation

The first subscript value (0) means "first row".

The second subscript value (1) means "second column" of that row.

Don't forget that index values start at 0.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?