comp 170 study guide 1 Dordal 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 many 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. In other words, you do *not* have to study how all these example projects work. 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, numbered as in the 4th edition (with 3rd edition numbers in parentheses): 3.1 3.2 3.3 3.6 3.7 > versus >= 3.8 && versus || 3.20 (3ed: 3.19) NumberDisplay.increment() 3.21 (3ed: 3.20) same Chapter 4: The biggie. The two biggest topics were: loops: while, for-each, classic-for (for the latter, reading only) 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 classic 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: (3rd-edition exercise numbers are in parentheses; ignore if you have 4th ed) 4.3 ArrayList size 4.4 ArrayList index values 4.5 same 4.6 method call using ArrayList.add() 4.7 removing items 4.8 index values after remove() 4.9 removeNote() 4.11 why we need loops 4.12 listNotes() 4.16 (3d: 4.15) range checking 4.17 (3d: 4.16) while loop to print multiples of 5 4.21 (3d: 4.20) modify listNotes() 4.23 (3d: 4.22) change indexing 4.27 (3d: 4.25) the Club lab 4.34 (3d: 4.32) Another Club example, done in class 4.42 (3d: 4.40) arrays 4.43 (3d: 4.41) arrays 4.45 (3d: 4.43) array declaration mistakes 4.46 (3d: 4.44) array examples 4.47 (3d: 4.45) trick question! 4.48 (3d: 4.46) array mistakes 4.49 (3d: 4.47) for loop; < versus <= 4.50 (3d: 4.48) for-to-while conversion 4.52 (3d: 4.50) while-to-for conversion ====================================================================== Example problems: These all involve writing part of a program; such problems tend to be hard. You will be given Notebook.java (on the website) as a source of examples. The exam WILL also have 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