Page 872 - AP Computer Science A, 7th edition
P. 872
22. (C) Segment II has an error in the getMove calls. References
c1 and c2 are of type Player, which doesn’t contain a getMove
method. To correct these statements a cast is necessary:
x = ((ExpertPlayer) c1).getMove();
and similarly for the c2 call. Note that c1.compareTo(c2) fails similarly and needs a cast for c1. Segment III fails because HumanPlayer does not have a compareTo method. A cast w on’t w ork here: You c an’t c as t a HumanPlayer t o an ExpertPlayer. Note that in segment I the getMove calls are fine and require no downcasting, since p1 and p2 are of type Player and Player has the getMove method.