1. False. The length of an array is always the value that it is initialized as, in this case 10. 2. True. Just like a variable of type A can hold a B object, an ArrayList of type A can hold B objects. 3. 1) It communicates to anyone looking at the code that this is a variable that will not change. 2) Java will enforce that and won't allow you to change it, avoiding accidentally changing it. 4. Returns the String that occurs most frequently in the ArrayList. O(n^2). 5. The mystery number is: 0 true -- The mystery number is: 10 false -- The mystery number is: 0 true -- 6. public void reverseFile(String infile, String outfile) { try { ArrayList lines = new ArrayList(); BufferedReader in = new BufferedReader(new FileReader(new File(infile))); PrintWriter out = new PrintWriter(new FileOutputStream(outfile)); String line = in.readLine(); // add all the lines in the file to an arraylist while( line != null ) { lines.add(line); line = in.readLine(); } // write them to the output file starting from the end for( int i = lines.size()-1; i >= 0; i-- ) { out.println(lines.get(i); } out.close(); in.close(); } catch (IOException e) { System.out.println("Something bad happened :("); } } 7. a. public void keep(int howMany){ if( howMany == 0 ){ head = null; } else { Node finger = head; // find the node before howMany things for( int i = 0; i < howMany-1 && finger != null; i++ ){ finger = finger.next(); } if( finger != null ) { finger.setNext(null); } } b. O(n). Worst case, have to traverse the entire list. c. No! The tail reference only gives us access to the end of the list, but that doesn't help finding the howManyith thing. d. No! The key thing is that we need to jump to a particular index. prev references don't make that any faster. 8. - Remove the last value - Swap two values - Remove all items: this assumes that you simply set size to 0 and do not null out the values in the array. 9. - Remove the first thing - Remove all items: simply set head to null