Computer Science 252
Problem Solving with Java
Spring 2016, The College of Saint Rose
Agenda
Due at the start of class, Thursday, February 4.
Please submit answers to these questions either as a hard copy (typeset or handwritten are OK) or by email to terescoj AT strose.edu by the start of class. Please use a clear subject line when submitting by email (e.g., CSC 252 Lecture 5 Assignment , Joe Student). We will discuss these questions at the start of class, so no late submissions are accepted.
Suppose you have the following instance variable declarations in a program:
private Location a, b, c;
and later in the program, the following statements are executed:
a = new Location(100, 100); b = new Location(200, 200); c = a; a.translate(25, -25); b.translate(10, 10); c.translate(15, 15);
What are the x and y coordinates in the Locations referenced by the variables a, b, and c?
==
operator and the
equals method.
Suppose you have the following instance variable declarations in a program:
private Location d, e, f;
and later in the program, the following statements are executed:
d = new Location(100, 100); e = new Location(100, 100); f = d;
Evaluate each of these expressions:
d == e d.equals(e) d == f d.equals(f)
Examples