The test is open-everything with the sole limitation that you neither solicit nor give help while the exam is in progress.
Since this is a timed, in-class, exam, you do not have to write comments in your code. Other aspects of good style, such as nice formatting and naming are still required, though.
| Problem | You got | Out of |
|---|---|---|
| 1 | 15 | |
| 2 | 15 | |
| 3 | 10 | |
| 4 | 10 | |
| 5 | 15 | |
| 6 | 15 | |
| 7 | 20 | |
| TOTAL | 100 |
|
|
public class Point {
private double x; private double y;
public Point(double x, double y) {this.x = x; this.y = y;}
public double getX() {return x;}
public void setX() {this.x = x;}
public double getY() {return y;}
public void setY() {this.y = y;}
}
Suppose your friend made a point....
Point home = new Point(10.62, 345.1);
Later your friend needed to move the point, but wanted to
"save" the old position first. So she does this:
Point oldHome = home; // save ("back up") the current position
home.setX(33.4);
home.setY(-810.6); // now home is (33.4,-810.6)
How can your friend move her home back to its old position? Should she
say home = oldHome;? Or home.setX(oldHome.getX());
home.setY(oldHome.getY());? Back up
your answer with object pictures like we saw in class.
String s = " a b c ";
s.trim();
System.out.println(s);
String s = "hello"; s = "world";(For full credit your answer has to be given in complete English sentences and you must use any technical jargon correctly.)
class Player {
public static String name;
private boolean isComputerPlayer;
public static double score;
double latitude;
double longitude;
}
Make a list of problems with this class. Your list must include
a discussion of what happens when trying to give each player his
or her own name.