wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Topic 7-2: 2D Array

Total questions: 6

Worksheet time: 4mins

Name
Class
Date
1.

Given the code, what is in values[2][1] ?

a)

8.0

b)

8

c)

4

d)

2.0

2.

Given the code, what is the value of values.length ?

a)

6

b)

3

c)

9

d)

7

3.

Given the following:

double [][] stuff ;

Which of the following statements constructs an array with 5 rows of 7 columns?

a)

stuff = new stuff[5][7] ;

b)

stuff = new double[5][7] ;

c)

new stuff = double[5][7] ;

d)

stuff = double new[5][7] ;

4.

What is the output of this code?

a)

1 2 3 4 5 7 8

b)

5 7 8

c)

7 8

d)

There are errors in the code

5.

Which of the following statements correctly declares a two-dimensional integer array?

a)

int Matrix[ ] = new int[5,4];

b)

int Matrix[ ]; Matrix = new int[5,4];

c)

int Matrix[ ][ ] = new int[5][4];

d)

int Matrix[ ][ ] = int[5][4];

6.

What would the statement values[1].length return?

a)

2

b)

3

c)

4

d)

9