comp 170 study guide 1 Dordal Exam: Monday, October 1, 2007 Here is a summary of the important sections covered. Our book uses what might be called a "total immersion" approach, and so a *lot* of topics come up in the first four chapters. I've tried to weed the list down a bit. As you've no doubt noticed, there are LOTS of example projects discussed in the book. The only one that appears on the exam is the Notebook in chapter 4, the second version (with a loop). Concepts from other projects will be covered on the exam, but in isolation, not in the context of the project. Chapter 1: objects, parameters, classes v instances, fields This is all at the level of a "first look"; it's all repeated later. Chapter 2: class definitions, constructors, accessors+mutators = methods conditional statements (if, else) local variables Important sections: 2.2 class definitions 2.3 fields, constructors, and methods 2.4 parameters 2.6,7 accessors,mutators 2.11 if statements 2.13 local vars 2.14 fields, parameters, and local vars I'm not suggesting any particular exercises from Chapter 2, as all that material is so heavily repeated in chapters 3 and 4. You won't have to write any methods "from scratch" for the exam, but you will have to identify return types and parameter types and be able to fill in the body of a method. Chapter 3: abstraction & modularization (This is hard to test for on an exam, but it's an important idea.) We build the clockDisplay out of *pieces*, in this case, out of two numberDisplay objects. This chapter also covered Strings, method calls, and object interaction Important sections: 3.6 class diagrams, object diagrams 3.7 primitive v Object types 3.8.2 String concatenation 3.9 Objects creating objects 3.10 Multiple constructors You do NOT need to know about the debugger or the "this" keyword for the exam. Some selected exercises: 3.1 3.2 3.3 3.6 3.7 > versus >= 3.8 && versus || 3.19 NumberDisplay.increment() 3.20 same Chapter 4: The biggie. The two biggest topics were: loops: while, for, for-each arrays & ArrayLists There were a few minor new topics mixed in with these two. array/ArrayList numbering ArrayList: add(), remove(), size() i++ versus i=i+1 null anonymous objects Important sections: 4.3 ArrayList library class / Notebook 4.4 collections 4.8.1 for-each loop 4.8.2 while loop 4.10.3 anonymous objects 4.12.2-4: arrays 4.12.6 for loops Iterators will NOT be on the exam. While you should be able to follow for loops, you won't have to write one. You *will* have to write while and for-each loops. Some selected exercises: (2nd-edition exercise numbers are in parentheses; ignore if you have 3rd ed) 4.3 (4.2) ArrayList size 4.4 (4.3) ArrayList index values 4.5 (4.4) same 4.6 (4.5) method call using ArrayList.add() 4.7 (4.6) removing items 4.8 (4.7) index values after remove() 4.9 (4.8) removeNote() 4.11 (4.10) why we need loops 4.12 (4.11) listNotes() 4.15 (4.14) range checking 4.16 (no) while loop to print multiples of 5 4.20 (4.15) modify listNotes() 4.22 (4.17) change indexing 4.25 (4.21) the Club lab 4.32 Another Club example 4.33 A harder Club example 4.40 (4.38) arrays 4.41 (4.39) arrays 4.43 (4.41) array declaration mistakes 4.44 (4.42) array examples 4.45 (4.43) trick question! 4.46 (4.44) array mistakes 4.47 (4.45) for loop; < versus <= 4.48 (4.46) for-to-while conversion 4.50 (4.48) while-to-for conversion ====================================================================== Example problems: These all involve writing part of a program; such problems tend to be hard. There will also be easier problems such as: format the following with reasonable indentation correct the syntax errors what does this program do? What is the output? Suggest a class (fields & methods) to accomplish a given task 1. Suppose we have an ArrayList notes All the actual notes are String objects. Write a loop to concatenate all the strings into one big one. String result = ""; int i = 0; while ( i