CS10, 09S, First Midterm Exam
What is covered
In general:
- Chapters 1-6, emphasizing the parts we talked about in lecture, on the homeworks, and on the programming assignments lab00, lab01, lab02
More specifically:
- Definitely: the basic idea of writing a class in Java with constructors, getters, setters and a toString method.
- The ideas of instance variables, methods, parameters.
- Declaring variables in Java, e.g. int x;
- Declaring variables that are references, and initializing, such as:
Student s = new Student("John", 1234567);
- Writing unit tests in JUnit (simple ones)
e.g.
public void testConstructor()
{
Student s = new Student("John", 1234567); // name and perm
assertEquals("John",s.getName());
assertEquals(1234567,s.getPerm());
}
- simple if tests, else (Sections 5.1, 5.3)
- simple for loops, while loops (as in the practice problems) (Sections 6.1, 6.2)
- anything else that was on the homework, lab assignments, or covered in lecture that I didn't mention here.
Here's a few additional topics that I didn't mention in class on Monday but are definitely covered by that last item (the anything else item above)...
A good way to study some of these is to look at the homework problems, your lecture notes, and also the "self-check" questions in the textbook (answers to those are in the book.)
- The compilation process (Section 1.8 in your text)
- The idea of Object references in general (2.10 in your text)
- Categories of variables (3.7 in your text):
- instance variables
- local variables
- parameter variables
- The this variable (an implicit parameter), (3.8 in your text)
- primitive types and type casting (4.1 in your text)
- assignment statements, increment/decrement operators (++,--), and order of operations (4.3 and 4.4 in your text)
- calling static methods (e.g. Math.sqrt(25.0)), from Section 4.5 in your text
- Strings (4.6 in your text)
- For this exam, you should know: declaring strings, using string constants, the .length() method, and using + for string concatenation.
- We'll defer coverage of the substring() method to Midterm 2
- if/else (Section 5.1, 5.3)
- relational operators (<, >, <=, >=, ==, !=) (Section 5.2.1)
- special concerns with testing floating point numbers for equality
(5.2.2)
- subtract, and check if the absolute value (Math.abs()) is less than some small value (called tolerance, or epsilon)
- special concerns with testing Strings and Objects for equality
(5.2.3, 5.2.4)
- The difference between
thisString == thatString, vs. thisString.equals(thatString)
- predicate functions (Section 5.4.2) —boolean functions that typically have names starting with is or has, like
myBankAcct.hasZeroBalance(), or myBankAccount.isOverDrawn().
- The boolean operators && and || (Section 5.4.3 of your text)
- DeMorgan's law (Advanced Topic 5.5 on p. 209 of your text)
Some things I won't cover on this exam, but which might be on Midterm 2
- Using Math.round with long variables
and using the class BigInteger and BigDecimal (from section 4.1)
- This isn't hard, but we just never talked about it or practiced with it. I'll try to correct that before Midterm 2.
- Binary numbers (from section 4.1)
- These will definitely be on Midterm 2, along with octal and hexadecimal.
- using final with constants (from section 4.2)
- Again, not hard, but we didn't practice with it yet—we'll fix that before Midterm 2
- The substring method from 4.6
- Reading User Input
(Section 4.7)
- The Scanner class and its methods
- Formatting numbers (Advanced Topic 4.6)
- The switch statement (Advanced Topic 5.2)
- enumerated types (Advanced Topic 5.3)
- The do while loop (Advanced topic 6.1)—though regular while loops are on this exam
- Nested Loops (section 6.3)—we'll practice with these with some homework problems before midterm exam 2
- Processing sentinel values (Section 6.4)—we'll practice with these on some programming assignments before midterm 2
- The graphics sections—this will definitely be on Midterm 2 though:
- 2.11G, 2.12G, 2.13G
- 3.9G
- Advanced Topic 4.7 (input dialog boxes)
- The sections in Chapter 6 on Debugging