Week 16: exam review
2013-05-06
Our final exam (on Wednesday, May 8) will cover all the major topics from the semester.
The main new topics since the last exam include:
- class inheritance
- applications of polymorphism
- exception handling
- Java collections classes
See this old exam
for some example problems and an example of the format (exact topics covered may
differ slightly). More example problems are below.
Example problems
- The function
Integer.parseInt
takes a String
as
input and returns the int
value it represents (for
example, 15
→ 15). It throws a NumberFormatException
if
the input cannot be converted to an int
. Write code that will
repeatedly prompt the user to input a number until the input can
successfully be converted to an int
.
- Define a class
GreetingCounter
that extends the class shown
below so that it has a method int helloCount()
that returns the
number of times the hello method has been called.
class Greeting {
private String name;
public Greeting(String name) { this.name = name; }
public void hello() { System.out.println("Hello " + name + "!"); }
}