C Sc 227 Test 1 Review Sheet Fall 2010

Quick Facts

  • 10:00-10:50 am Friday, 17-Sep-2010 where we have lectures: 301 BIO W
  • Everyone must have an aisle or two empty seats on either side of you
  • This Test is 15% of your final grade
  • Closed books, closed notes
  • Use pencil, not pen (please)
  • No electronic devices such as mp3 players.
  • You do not need a calculator (integer division differs in Java anyway)

Types, both primitive (int, char, double) and reference (String, Scanner, String227)

  • Evaluate expressions with int and double
  • Integer arithmetic: 5 / 2 is 2, 5 % 2 is 1
  • Know these Math functions:

assertEquals(2.0, Math.sqrt(4.0), 1e-12)

assertEquals(-6, Math.max(-6, -7))

assertEquals(2, Math.round(1.501))

assertEquals(2.3, Math.abs(5.3 – 7.6), 0.01)

  • Output with print and println
  • Assignment compatibility rules
  • Boolean expressions with relational operators, !=, ==, and Boolean operators & || !

If you cannot write &, write AND on the test,

  • String methods: length, compareTo, substring, indexOf, charAt
  • Scanner object with a String argument at construction using hasNextInt() / nextInt() for string arguments containing integers, or hasNexDouble() / nextDouble() for string arguments containing doubles, or hasNext () / next() for string containing any text separated by whitespace (blanks, \n, or \t)

See practice test question #4, occurencesOf (and the answer)

  • Construct objects with constructors: String227(char[]);
  • Send messages to objects: objectReference.messageName(argumentsoptional)

Classes, Methods, Parameters, Testing

  • Understand method headings, parameters, flow of control when a method is called
  • JUnit: assertEquals, assertTrue, and assertFalse in test methods that are preceded with @Test
  • Add methods to classes that have private instance variables and a constructor (String227 specifically)

Control Structures

  • if statements, if...else, and nested if...else statements
  • for loops (known number of repetitions)
  • while loops (unknown number of repetitions)

Arrays 1D

  • Show output from code with an array, declare arrays,
  • Process array data: find high, low, average, print all elements in an array
  • Send messages to objects stored in an array names[0].substring(1, 6);
  • Swap two values as is done to rearrange two array elements

Resources

  • Section Leader Review session: Wednesday, 15-Sep, 6:30 - 8:00pm in 701 Gould Simpson
  • Code demos Page
  • Chapters 2-10 in Rick’s Book with Self-Checks Questions and Answers at the end of each chapter
  • Presentations 2-10
  • The Practice test handed out Monday and answers linked Wednesday morning
  • Today's section that will be a test review session
  • Your projects and homework
  • Nick Paralante's JavaBat problems that are designed to help Computer Science students study for CS tests