Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Topic 7-3: Array

Total questions: 6

Worksheet time: 6mins

Name
Class
Date
1.

Which code line could possibly "call" this method?        

public static int SomeMethod(double[ ] array, int[ ] number) { . . . }

a)

int value = SomeMethod(money, grades);

b)

SomeMethod(money, grades);

c)

double value = SomeMethod(money, grades);

d)

int value = SomeMethod(money);

2.

What is the length of this array? 

double[ ] stuff = {1.5,  2.5,  3.5,  4.5,  5.5,  6.5};

a)

1

b)

5

c)

6

d)

7

3.

What is the output from the following code fragment?

String [ ] name = { "Joe", "Sue", "Tom", "Jill", "Patty"}; 

for (int i = 0; i < name.length; i = i + 2) 

System.out.print(name[i] + " ");

a)

Joe Sue Tom Jill Patty

b)

Patty Jill Tom Sue Joe

c)

Joe Tom Patty

d)

Sue Jill

4.

What is the output of the following code fragment?

double [ ] x = new double [ 4]; 

x[0] = 8.5;

x[1] = 6.5;

x[2] = 9.5;

x[3] = 12.5; 

System.out.println(x[1 + 2]);

a)

6.5  9.5

b)

12.5

c)

15.0

d)

9.5  12.5

5.

What number is in matrix[2][2]?

int [ ] [ ] matrix = { {1, 2, 3, 4},{5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}};

a)

6

b)

7

c)

10

d)

11

6.

Which of the following declares an array of integers named number?

a)

int number;

b)

int [ ] number;

c)

int new number [ ];

d)

int number = int [ ];