CSC 222: Object-Oriented Programming
Spring 2017

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 Model-View-Controller pattern model: classes that implement the logic of the program view: the interface through which the user interacts controller: the class that connects the model with the view Java features 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) enumerated types can define a new type by listing all of its possible values refer to values as ENUMTYPE.VALUE example: CaveContents.EMPTY, CaveContents.WUMPUS 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 Dr. Suess analogy insertion sort vs. selection sort vs. merge sort vs. quick sort worst case vs. average case vs. best case performance application: Dictionary class, lazy add approach Big-Oh analysis insertion & selection sorts are O(N^2), merge & quick sorts are O(N log N) rate of growth behavior