"The only test of the utility of Knowledge, is its promoting the happiness of mankind." — Dr. STARK on Diet, p. 90.
From the exam description:
Given a design scenario, determine which collection classes and/or interfaces should be used to properly implement that design, including the use of the Comparable interface.
1.1 Collections interfaces
1.2 Collections classes
1.2.1 List
1.2.1.1 Vector
1.2.2 Set
1.2.2.1 HashSet (unordered iterator)
1.2.2.2 TreeSet (ordered iterator; implements SortedSet, uses Comparable)
1.3 Artifacts
1.3.1 Vector use
1.3.2
2 Distinguish between correct and incorrect overrides of corresponding hashCode and equals methods, and explain the difference between == and the equals method.
2.1 hashCode method
2.1.1 Contract
Defined in java.lang.Object API
* If x.equals(y) then x.hashCode() == y.hashCode()
* The hashCode may be equal for different objects
2.1.2 Overrides of hashCode
The hashCode method must conform to the contract.
2.2 equals method
2.2.1 Contract
Defined in java.lang.Object API
* x.equals(x) is true (reflexive)
* if y.equals(x) then x.equals(y) (symmetric)
* if x.equals(y) and y.equals(z), then x.equals(z) (transitive)
* x.equals(null) is false (where x is not null)
Notion of equality based on value, not reference. A confusing point int the documentation is that java.lang.Object.equals() uses the == operator. This is because there are no fields in Object to compare; its only distinguishing value is its reference.
Arrays are objects as well, and inherit the object methods.
2.2.2 Overrides of equals
The equals method must conform to the contract.
Generally if equals() is overridden then hashCode() is overridden as well. The relationship between equals and hashCode is part of their contract.
2.3 Artifacts
2.3.1 Code that implements equals() and hashCode() correctly
2.3.2 Counter example (how to test this? induce bad behavior in collections framework?)
3 Write code that uses the generic versions of the Collections API, in particular, the Set, List, and Map interfaces and implementation classes. Recognize the limitations of the non-generic Collections API and how to refactor code to use the generic versions.
3.1 Generic collections
3.1.1 Set interface
3.1.2 List interface
3.1.3 Map interface
3.2 Limitations of the non-generic Collections
3.2.1 Cast requirements
3.2.2 Type checking
3.2.3 ??
4 Develop code that makes proper use of type parameters in class/interface declarations, instance variables, method arguments, and return types; and write generic methods or methods that make use of wildcard types and understand the similarities and differences between these two approaches.
4.1 Generic declarations with type parameters
4.1.1 Definition
4.1.2 Class declarations
4.1.3 Interface declarations
4.1.4 Instance variables
4.1.5 Method arguments
4.1.6 Return types
4.2 Generic declarations with wildcard types
4.2.1 Definition
4.2.2 ??
5 Use capabilities in the java.util package to write code to manipulate a list by sorting, performing a binary search, or converting the list to an array. Use capabilities in the java.util package to write code to manipulate an array by sorting, performing a binary search, or converting the array to a list. Use the java.util.Comparator and java.lang.Comparable interfaces to affect the sorting of lists and arrays. Furthermore, recognize the effect of the "natural ordering" of primitive wrapper classes and java.lang.String on sorting.
5.1 Using the java.util package, write code to do the following:
5.1.1 Sort a list
5.1.2 Perform a binary search (on a list?)
5.1.3 Convert list to array
5.1.4 Sort an array
5.1.5 Perform a binary search on an array
5.1.6 Convert an array to a list
5.2 Use the java.util.Comparator and java.lang.Comparable interfaces to affect
5.2.1 Sorting of lists
5.2.2 Sorting of arrays
5.3 Understand the natural ordering of primitive wrapper classes and java.lang.String
5.3.1 Define (See http://java.sun.com/docs/books/tutorial/collections/interfaces/order.htm...)
5.3.1.1 Elements that can be compared to one another are mutually comparable.