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

Задача . 37405


Задача

Темы:
Consider the following hierarchy of classes:

A program is written to print data about various birds:
public class BirdStuff
{
 public static void printName(Bird b)
  { /* implementation not shown */ }
 public static void printBirdCall(Parrot p)
  { /* implementation not shown */ }
//several more Bird methods
 public static void main(String[] args)
  {
  Bird bird1 = new Bird();
  Bird bird2 = new Parrot();
  Parrot parrot1 = new Parrot();
  Parrot parrot2 = new Parakeet();
/* more code */
 }
}

Assuming that none of the given classes is abstract and all have default constructors, which of the following segments of /* more code */ will not cause an error?
(A) printName(parrot2);
      printBirdCall((Parrot) bird2);
(B) printName((Parrot) bird1);
     printBirdCall(bird2);
(C) printName(bird2);
      printBirdCall(bird2);
(D) printName((Parakeet) parrot1);
      printBirdCall(parrot2);
(E) printName((Owl) parrot2);
      printBirdCall((Parakeet) parrot2);

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

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