wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

2D Array Test

Total questions: 20

Worksheet time: 45mins

Name
Class
Date
1.

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

a)

7.9

b)

9.2

c)

7.3

d)

0.5

2.

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

a)

4

b)

3

c)

12

d)

7

3.

Given the following:

double [][] stuff ;

Which of the following statements constructs an array with 5 rows of 7 columns each and assign its reference to stuff ?

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.

Given the code, which of the following fragments prints out every element of items?

a)
b)
c)
d)
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 a[1].length return?

a)

3

b)

4

c)

2

d)

1

7.
What value is at index 1 in this array?  String[] names = {"Mack", "Dennis", "Dee", "Charlie"};
a)
Mack
b)
Dennis
c)
Dee
d)
Charlie
8.
True or False:  An array can be store different types of data (like store both doubles and ints).
a)
True
b)
False
9.
a)

a

b)

b

c)

c

d)

d

10.
a)

a

b)

b

c)

c

d)

d

11.
a)

a

b)

b

c)

c

d)

d

12.
a)

a

b)

b

c)

c

d)

d

13.
a)

a

b)

b

c)

c

d)

d

14.
a)

a

b)

b

c)

c

d)

d

15.
a)

a

b)

b

c)

c

d)

d

16.
a)

a

b)

b

c)

c

d)

d

17.
a)

a

b)

b

c)

c

d)

d

18.
4 lines
19.
a)

a

b)

b

c)

c

d)

d

20.

What are the contents of mat after the code has been executed.

a)
b)
c)
d)
e)