CSE143 – Miniquiz #2
01/14/2003
Name:
Section:
The following questions are based on the code fragment below defining a class Lake:
public class Lake
implements BodyOfWater
{
private int depth;
public void fillWithWater(){
//implementation
code//
}
public void drainWater(){
//implementation
code//
}
}
Questions:
1) True or false? The code defining BodyOfWater could have the following form:
public class BodyOfWater
{
//some
methods and variables//
}
FALSE
2) True or false? The variable depth could be defined in BodyOfWater exactly as it appears in class Lake.
FALSE
3) True or false? Methods in BodyOfWater can have a body (ie, implementation).
FALSE
4) True or false? An instance of Lake can be assigned to a variable of type BodyOfWater.
TRUE
5) Suppose that BodyOfWater defines 3 methods named fillWithWater, canSwimIn, isEmpty. True or false? The above code fragment defining class Lake is allowable.
FALSE