Java Name -
Array Worksheet #2
1. Write a statement that declares a reference to an array of int’s. The array reference should be named
numbers.
2. Write a statement that declares and constructs an array of Rectangle’s named boxes so that the array
stores exactly 10 Rectangle objects.
3. Write a SINGLE statement that declares a reference to an array named grades that stores five
double's. In the same statement, initialize the array to the values 44, 55, 66, 77, and 88.
4. Write a statement that assigns the value 13 to the fifth position of the array numbers.
5. Write a statement that displays the value stored in the third position of the array numbers.
6. Write a statement that displays the number of elements in the array named numbers.
7. Write a SINGLE statement that stores the value 99 into the last position of an array named grades no
matter how many elements it has.
8. Write a for loop that assigns the integer values 1 through 10 to the first ten positions of an array named
scores. You can assume that the array scores has already been declared and constructed to have 10
elements.
9. Write a statement that declares a constructs a two-dimensional array of int’s named sportsScores
that has exactly 5 rows and 4 columns.
10. Write a statement that assigns the value 13 to the element in the third row and the second column of the
two-dimensional array named sportsScores.
11. On the back of this worksheet, write a static method named findPosition that accepts two
parameters, an int named key and an array of int’s named numbers. The method must return the
subscript position within numbers in which key is found. Return the value -1 if key is not stored in the
array.
public static int findPosition(int key, int[] numbers)
{