Which of the following declares an array variable of type String and then creates a String array with 12 elements? A) char *arr = new arr[12][10]; B) apstring arr[12]; C) String arr[] = new arr[String * 12]; D) String[] arr = new String[12]; E) none of the above
new int[200] creates an integer array with indexes between A) 1 and 200 B) 0 and 199 C) 1 and 199 D) 0 and 200 E) none of the above
In order to access the first element of an array called arr, you would use the following line fragment: A) arr[1] B) [1]arr C) arr.getitem(0) D) arr[0] E) none of the above
Given a 2-dimensional array cletus, what line fragment would tell you how many columns (the first of the two indices) the array held? A) cletus[][].length() B) cletus.length(); C) strlen(cletus) D) cletus.arraylength(); E) none of the above
To get the number of elements in a single-dimensional ArrayList called RayJay, one would say A) RayJay.length() B) RayJay[].length() C) RayJay.size() D) strlen(RayJay) E) none of the above
Which of the following sets the first index of an ArrayList of Strings called frink to “glaven!”? A) frink[0] = “glaven!”; B) frink.set(0, “glaven!”); C) frink[1] = “glaven!”; D) “glaven!” = frink[0]; E) none of the above
To increase the length of an ArrayList by 1, one could use the following ArrayList method: A) get B) set C) remove D) add E) none of the above
For the following questions write on your answer sheet T if the statement is true, F otherwise
It is illegal to do the following to an array of type Turtle; one must instead cast the Turtle object back into a Turtle variable from the array: Turtles[2].swingAround(10);
A three-dimensional array is not possible in Java
If an array is of type Object, it can actually store any Object derived types within it.
The following will define an array with 3 elements: int[] arr = {0, 1, 2, 3};
Every element in an ArrayList is actually stored as type Integer
In order to remove an element from an ArrayList, one uses the delete method in ArrayList
“it takes two to lie. One to lie and one to listen. “
“When I die, I want to go out peacefully in my sleep, like my grandfather. Not screaming and yelling like the passengers in his car”
For the remaining questions, write code to implement the requested method INCLUDE COMMENTS for full credit
Write code to declare an ArrayList of Strings consisting of the Strings "baz", "foo", and "bar" Worth 2 points
What does the value of garply after the code below executes represent (you can assume the array is of type int and has at least one element)? Worth 2 points:
int total = 0; double garply = 0;
for (int a = 0; a <
arr.length; a++) {
total = total + arr[a];
}
garply = total / arr.length;
Given an ArrayList of Strings called Sauron, write code that will store the last value in the ArrayList into a String called Meanie. (you can assume Meanie is already declared) Worth 2 points