CSC 222: Object-Oriented Programming
Fall 2015

Test 2 Review


TEST 1 MATERIAL Object-oriented design classes & objects highly cohesive each class maps to a single, well-defined entity each method of the class maps to a single, well-defined behavior loosely coupled each class is largely independent and interacts via well-defined interface method behavior should not depend upon coordination with other methods example: dot race, text vs. visual views Java features ArrayList generic, must specify the type of object stored wrapper classes (Integer, Double, ...) allow for storing primitives methods: add, get, size, remove, contains, set, indexOf, toString, ... traversal using for loop vs. for-each loop underlying array data structure can be used directly if size of list is set, but more primitive data structures ArrayLists vs. arrays parallel lists vs. lists of structured objects example: ArrayList of WordCount objects interacting classes exception handling throwing an exception vs. try-catch input/output Scanner class used to read from keyboard (System.in) or a file (File object) methods: hasNext, next, hasNextLine, nextLine, hasNextInt, nextInt, close, ... System.out.format, format string (e.g., %8s, %-8s, %.2f, %6.2f) interfaces & polymorphism defining and implementing an interface Comparable interface, List interface, Collections.sort generic methods, polymorphism Searching and efficiency sequential search vs. binary search worst case vs. average case vs. best case performance timing performance, System.currentTimeMillis Collections.binarySearch application: Dictionary class Big-Oh notation sequential search is O(N), binary search is O(log N) rate-of-growth behavior Sorting and recursion recursion base case(s), recursive case(s) avoiding infinite recursion & redundancies insertion sort vs. selection sort vs. merge sort worst case vs. average case vs. best case performance implementing an O(N) merge application: Dictionary class, lazy add approach Big-Oh analysis insertion & selection sorts are O(N^2), merge sort is O(N log N)