Олимпиадный тренинг

Задача . 22


Задача

Темы:
public interface Player
{
/** Return an integer that represents a move in a game. */
  int getMove();
/** Display the status of the game for this Player after
* implementing the next move. */
  void updateDisplay();
}

public class HumanPlayer implements Player
{
 private String name;
//Constructors not shown ...
//Code to implement getMove and updateDisplay not shown ...
 public String getName()
 { /* implementation not shown */ }
}
public class ExpertPlayer extends HumanPlayer
{
 private int rating;
//Constructors not shown ...
 public int compareTo(ExpertPlayer expert)
 { /* implementation not shown */ }
}

Which code segment in a client program will cause an error?
I) Player p1 = new HumanPlayer();
Player p2 = new ExpertPlayer();
int x1 = p1.getMove();
int x2 = p2.getMove();

II) int x;
Player c1 = new ExpertPlayer(/* correct parameter list */);
Player c2 = new ExpertPlayer(/* correct parameter list */);
if (c1.compareTo(c2) < 0)
  x = c1.getMove();
else
  x = c2.getMove();

III) int x;
HumanPlayer h1 = new HumanPlayer(/* correct parameter list */);
HumanPlayer h2 = new HumanPlayer(/* correct parameter list */);
if (h1.compareTo(h2) < 0)
  x = h1.getMove();
else
  x = h2.getMove();

(A) II only
(B) III only
(C) II and III only
(D) I, II, and III
(E) None

time 1000 ms
memory 32 Mb
Правила оформления программ и список ошибок при автоматической проверке задач

Статистика успешных решений по компиляторам
Комментарий учителя