1. T/F: The following code will print out 1: String[] strings = new String[10]; strings[0] = "banana"; System.out.println(strings.length); 2. T/F: Given a class B that extends class A, the following code is legal (will compile and run) assuming B has a zero parameter constructor: ArrayList a = new ArrayList(); B b = new B(); a.add(b); 3. What is the benefit of using the "final" keyword? 4. What does this method do and what is the big-O runtime? public String mystery(ArrayList input ){ String mysteryVar = ""; int c = 0; for( int i = 0; i < input.size(); i++ ){ int num = 1; for( int j = i+1; j < input.size(); j++ ){ if( input.get(i).equals(input.get(j))){ num++; } } if( num > c ){ c = num; mysteryVar = input.get(i); } } return mysteryVar; } 5. What does the main method in the Mystery class below print out? public class Mystery { private int mystery; private int original; public Mystery(int m){ mystery = m; original = m; } public void mystery1(int num){ mystery += num; } public void mystery2(){ mystery = original; } public boolean mystery3(){ return mystery == original; } public String toString(){ return "The mystery number is: " + mystery; } public static void main(String[] args){ Mystery m = new Mystery(0); System.out.println(m); System.out.println(m.mystery3()); System.out.println("--"); m.mystery1(10); System.out.println(m); System.out.println(m.mystery3()); System.out.println("--"); m.mystery2(); System.out.println(m); System.out.println(m.mystery3()); System.out.println("--"); } } 6. Write a method called reverseFile that reverses the ordering of the lines in a file. (Hint: use an ArrayList). 7. a. Write a method "keep" for our LinkedList class that takes a number (howMany) and keeps the first howMany items in the LinkedList, i.e., makes the list of length howMany. If the list has less than howMany items, nothing changes. You can assume we're using the singly linked list with just a head reference. public void keep(int howMany) b. What is the worst-case big-O runtime of your method? c. Could you write this method more efficiently (with respect to worst-case big-O) runtime if you had a tail reference? You don't need to write the code, just state whether it would help and give a brief justification. d. Could you write this method more efficiently (with respect to worst-case big-O) runtime if you had a tail reference and it was a doubly linked list? You don't need to write the code, just state whether it would help and give a brief justification. 8. Which of the following things could be done fast (O(1)) in the worst case on an ArrayList: - Remove the first thing from the list - Remove the last thing from the list - Remove a value at a particular index in the list - Swap two values in the list, given their indices - Remove all items from the list, i.e., clear the list (justify your answer for this one) 9. Which of the following things could be done fast (O(1)) in the worst case on a singly LinkedList with a tail reference: - Remove the first thing from the list - Remove the last thing from the list - Remove a value at a particular index in the list - Swap two values in the list, given their indices - Remove all items from the list, i.e., clear the list.