WorksheetsTopic 7-3: Array
Total questions: 6
Worksheet time: 6mins
Which code line could possibly "call" this method?
public static int SomeMethod(double[ ] array, int[ ] number) { . . . }
int value = SomeMethod(money, grades);
SomeMethod(money, grades);
double value = SomeMethod(money, grades);
int value = SomeMethod(money);
What is the length of this array?
double[ ] stuff = {1.5, 2.5, 3.5, 4.5, 5.5, 6.5};
1
5
6
7
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] + " ");
Joe Sue Tom Jill Patty
Patty Jill Tom Sue Joe
Joe Tom Patty
Sue Jill
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]);
6.5 9.5
12.5
15.0
9.5 12.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}};
6
7
10
11
Which of the following declares an array of integers named number?
int number;
int [ ] number;
int new number [ ];
int number = int [ ];
