CSC 222: Object-Oriented Programming
Test 1 Review

Thu, Oct 8
  • The test will include extra points (Mistakes Happen!), e.g., 52 or 53 points, but graded on a scale of 50.

Types of questions
  • factual knowledge: TRUE/FALSE, multiple choice
    TRUE or FALSE: In Java, an attempt to compare two String values using == will result in an error.
  • conceptual understanding: short answer, discussion
    Object-oriented design is a popular approach in the development of large software systems. What is the basic idea behind object-oriented design? That is, when faced with a problem to be solved, what aspects of the problem does object-oriented design focus on first?
  • synthesis and application: explain/debug code, trace/modify code
    Given the definition of the Coin class, write a code segment that creates and initializes a Coin object named quarter and repeatedly flips it (and prints the flip) until two heads in a row are obtained.
Study advice
  • review online lecture notes
  • review the text book (if not mentioned in class, won't be on test)
  • look over quizzes, homework assignments
  • reference other sources for examples, different perspectives
  • practice solving problems on
Course material Object-oriented design goals abstraction: ignore details to focus attention on higher level of problem object-focused: identify the objects in the real-world system & model each with a class modularization: design each class/method to be well-defined & self-contained, so that they can be built/examined separately & reused easily Java classes using classes loading a BlueJ project, creating an object, inspecting an object's state calling a method, parameters, return values defining/examining classes fields: maintain the state of an object access using this. prefix can be static (shared by class) and/or final (unchangeable) constructor(s): initialize the fields for a newly created object methods: implement the behaviors of the method accessor method returns a field value; mutator method changes field(s) can define local variables for temporary values must specify return type (void if no return) class/constructor/methods are (usually) public; fields are (usually) private comments (/** ... */ or // ..) are for documentation Java statements assignment statements data types (String, int, double, char, boolean) variables, expressions (+, -, *, *, %) arithmetic assignments: +=, -=, *=, /=, ++, -- primitive types vs. object types (using new) variable scope (field = entire class; parameter/local = that method only) output statements System.out.print, System.out.println return statements conditional statements 1-way: if; 2-way: if-else; multi-way: cascading if-else comparison operators: ==, !=, <, >, <=, >= (danger: = vs. ==) logical connectives: && (AND), || (OR), ! (NOT) repetition statements while: conditional repetition for: counter-driven repetition (shorthand version of while loop) for-each: for traversing a list (shorthand version of for loop) method calls internal call: this.METHOD(PARAMETERS) external call: OBJECT.METHOD(PARAMETERS) Java library classes String implicit call to new when assigning, immutable methods: length, charAt, contains, indexOf, substring, toUpperCase, toLowerCase, equals, compareTo, ... Character static methods: toUpperCase, toLowerCase, isLetter, isUpperCase, isLowerCase, ... Integer static method: parseInt Random methods: nextInt, nextDouble, ... 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 Input/Output Scanner class used to read from keyboard ( or a file (File object) methods: hasNext, next, hasNextLine, nextLine, hasNextInt, nextInt, close, ... FileWriter class used to write to a file methods: write, close