Here are a variety of methods that you will need to know for the AP test. They are also useful in general, so learn them and love them.

toString is used in case you wish to print an object to standard output. It is wise to put some key identifying characteristic(s) of the object into the String that toString returns. For example, suppose you have a Cow class, and you create an object of type Cow called bessie. What would you want to see displayed if you were to do System.out.println(bessie)? The toString method in the Cow class will dictate what is shown. If there is no toString method in the Cow class, then Java defaults to the memory location of the object. In a lower level language, or if you were poking around in your computer's memory, that might be interesting, but for the purpose of this class, that output probably won't be helpful.

equals is used to test if two objects are to be considered the same. The criteria used for determining that are up to the programmer. Failure to put an equals method into a class will result in objects being tested to see if they are literally identical which is what == does.

One of the most common mistakes that I see in this regard comes with String objects. It is often never detected because of how Java stores Strings. Assuming that str1 and str2 are both Strings, the expression (str1 == str2) does not check to see if the contents of the two are the same. Rather, it is a test to see if the two are literally in the same location in memory. Better practice is to use str1.equals(str2) which is written to see if the contents of the Strings are the same.

compareTo is used to test if one object is greater than, less than, or equal to another. The meanings of greater than and less than are left to the programmer. For example, if we have two cows, bessie and dannybigtimejones, bessie.compareTo(dannybigtimejones) might return 1 if bessie weighs more, -1 if dannybigtimejones weighs more, and 0 if they have the same weight. If you don't want to compare them based on weight, then you can choose some other criteria by which to compare them. For compareTo to work properly, the class in which the method is placed must implement the Comparable interface.