CS 141 Fall 2012 -- Final review

The final will cover all the material from the entire course. So, the first thing to review is the two previous review pages the are: here, and here.
Plus, there's the new material since the second midterm. It includes:
  1. File I/O
  2. ArrayList<Foo>
    1. Creating as a FooList
    2. Adding Foos
    3. Iterating over a FooList
      1. to display
      2. to find/return a Foo with particular value in some field
    4. Sorting an ArrayList
      1. Using a Comparable
      2. Using a Comparator

Sample questions (in addition to those in the two previous review sheets!)

  1. Write a complete Song class, with variables for the title and the length (in seconds). Include accessors for both variables, toString(), output(MyWriter) and Song(MyReader). Assume the format of the input file is name and length on separate lines.
  2. Write a complete SongList class which extends ArrayList<Song> and has an input method to read from a file and a public String toString() method that returns each song's info on a separate line.
  3. Write a find(String, SongList) method which is passed a song title to find and a SongList and returns the Song with that title, or null if that title is not found
  4. Write a method SongList longerThan(SongList, int), which is passed a SongList and an int, and returns another SongList containing all the songs in the parameter list which are longer than the int parameter.
  5. Write a method that souts all the titles of the Songs in a SongList parameter, one per line
An exam from 2007
An exam from 2010