Exam II Study Guide
The following topics will be covered on Exam II:
- Methods
-
- What is the anatomy of a method declaration and body?
- What is the difference between static and non-static methods?
- What happens at a return statement?
- You should be able to write methods to do any of the tasks we have discussed in this course: in lecture,
in studio, in labs.
For review, look at Sedgewick problems
2.1.1–2.1.5 (5 problems), 2.1.13–2.1.15 (3 problems), 2.1.22
- Recursion
-
- What is a base case in a recursive method?
- Given a recursive method, use the substitution model to show how the method computes its result.
- Given a recursively defined function, write the Java method that computes that function.
- Given a picture or a formula, identify the recursive substructure of that formula.
- Having found recursive substructure, express a picture or formula as a recursive method in Java.
- You should be able to write recursive methods to do any of the tasks we have discussed in this course:
in lecture, in studio, in labs.
For review, look at Sedgewick problems
2.3.1, 2.3.3, 2.3.4, 2.3.8 (You can implement this and figure out what it does.
I consider it extra credit to explain why it does what it does. Hint:
consider the representation of a and (especially) b in base 2.)
- Objects
-
- What is an object and how are objects defined in Java?
- What is the syntax for calling a method on an object and passing that method some parameters?
- What is the anatomy of a Java class?
- What is the difference bewteen an instance variable and a local variable?
- What is has-a and how do we use has-a statements when designing Java classes?
- How do you recognize a constructor in a Java class, and what is its purpose?
- What does it mean for a class to be immutable, and what role does final play in declaring
the instance variables (fields) of immutable classes?
- What is toString() and how is it used to provide information about an instance?
- What is equals(Object obj) and how does it differ from ==?
For review, look at Sedgewick problems
3.2.1–3.2.4 (4 problems), 3.2.7, 3.2.8