Page 246 - AP Computer Science A, 7th edition
P. 246

(B) IIIonly
(C) IIandIIIonly (D) I, II, and III (E) None
23. Which of the following is correct implementation code for the compareTo method in the ExpertPlayer class?
I
II III
(A) (B) (C) (D) (E)
if (rating == expert.rating) return 0;
else if (rating < expert.rating) return –1;
else
return 1;
return rating – expert.rating;
if (getName().equals(expert.getName())) return 0;
else if (getName().compareTo(expert.getName()) < 0)
return –1; else
return 1;
Ionly
IIonly IIIonly IandIIonly I, II, and III
24. Which of the following classes is the least suitable candidate for containing a compareTo method?
(A) public class Point {
private double x;















































































   244   245   246   247   248