Professional Documents
Culture Documents
cs61b Fa01 mt1
cs61b Fa01 mt1
CS 61B
Midterm #1
Fall 2001
Professor Paul Hilfinger
Throughout this test, assume that the following definitions are available.
class IntList {
public int head;
public IntList tail;
/** The IntList whose head is HEAD and whose tail is TAIL. */
public IntList (int head, IntList tail) { ... }
a. Your Java program keeps throwing a ClassCastException on a line of your program that reads
where values is a java.util.Stack. As a first step in figuring out what's going on, you want to find out what
value is about to be popped at this point. Tell what commands you would give gjdb to find out.
b. I add a new source file, mymath/Vector.java, to my mcalc project, but don't change my Makefile.
Usually, comilation (with gmake) continues to work, but occasionally, something goes wrong. What, and
under what conditions?
{
List L = createList();
fillValues(L);
if (L.contains (x)) {...
TheProgram stops with a NullPointerException at the if statement, so the student knows that L must be null.
He tells you that he guesses this is caused by a problem with