Array Review
From Huben's Wiki
(Created page with "<code>1. int values[] = {1,2,3,4,5,6,7,8}; for(int i=0; i< X; i++) System.out.println(values[i]); Referring to the above, what value for X will print all members of array "...") |
|||
Line 7: | Line 7: | ||
A) 1 B) 9 C) 7 D) 8 | A) 1 B) 9 C) 7 D) 8 | ||
E) None, since there is a syntax error in the array declaration | E) None, since there is a syntax error in the array declaration | ||
+ | |||
2. int[] number = new int[5]; After execution of this statement, which of the following are true? | 2. int[] number = new int[5]; After execution of this statement, which of the following are true? | ||
(A) number[0] is 5 | (A) number[0] is 5 | ||
Line 13: | Line 14: | ||
(D) number[2] is 0 | (D) number[2] is 0 | ||
(E) number.length() is 5 | (E) number.length() is 5 | ||
+ | |||
3. What does | 3. What does | ||
double table[]; | double table[]; | ||
Line 33: | Line 35: | ||
5. Declare and create a one-dimensional array called B with 5 elements of type integer. | 5. Declare and create a one-dimensional array called B with 5 elements of type integer. | ||
+ | |||
6. Declare and initialize a one-dimensional array called C with the following values: | 6. Declare and initialize a one-dimensional array called C with the following values: | ||