One-page version suitable for printing.
Statistics:
(All numbers are out of the possible 80 points, including the 5-point curve.)mean 64.073 (2627.000/41) stddev 11.785 median 64.000 midrange 53.250-74.000 # avg 1 7.95 / 10 2 15.05 / 25 3 21.15 / 25 4 7.83 / 10 5 7.20 / 10 (+ 5-point curve)
Select which of the following best describes the purpose of each of the circled pieces of the code. (Note that some choices may not appear at all, and others may occur multiple times.)
A. class method definition
B. instance method definition
C. constructor method definition
D. class variable declaration
E. instance variable declaration
F. local variable declaration
[25 pts] Suppose somebody has already written for us two classes Bank and Account.
Bank class documentation | Account class documentation |
|
|
Bank duplicateBank(Bank b) { }
Define a class PassCount to track whether all the students of a class have passed a test. It should support the following methods.
public class PassCountTest { public static void run() { PassCount a = new PassCount(); a.addGrade(45.0); a.addGrade(76.0); IO.println(a.isAnyFailing()); // should print ``true'' PassCount b = new PassCount(); b.addGrade(60.0); IO.println(b.isAnyFailing()); // should print ``false'' } }
[10 pts] Suppose we have the following two class definitions.
class P { public int f(int x) { return x + 1; } public int g(int x) { return f(x + 2); } } | class Q extends P { public int f(int x) { return x + 4; } public int h(int x) { return f(x + 8); } } |
public static void run() { P a = new P(); Q b = new Q(); P c = b; IO.println(a.f(0) + " " + a.g(0)); IO.println(b.f(0) + " " + b.g(0) + " " + b.h(0)); IO.println(c.f(0) + " " + c.g(0)); }
[10 pts] Suppose we have the class defined as below.
class C { static int y = 0; int z; C() { z = 0; } void incrX() { int x = 0; x++; IO.println(x); } void incrY() { y++; IO.println(y); } void incrZ() { z++; IO.println(z); } } | public class Example { public static void run() { C a = new C(); C b = new C(); a.incrX(); a.incrX(); b.incrX(); a.incrY(); a.incrY(); b.incrY(); a.incrZ(); a.incrZ(); b.incrZ(); } } |