У меня есть проблема в понимании Вопрос № 9 от главы ориентации объектов из книги SCJP от K & B.SCJP Объект Ориентация Issue
Вопрос:
public class Redwood extends Tree {
public static void main (String [] args) {
new Redwood () . go () ;
}
void go () {
go2 (new Tree () , new Redwood ()) ;
go2 ((Redwood) new Tree () , new Redwood (]
}
void go2 (Tree tl, Redwood rl) {
Redwood r2 = (Redwood) tl;
Tree t2 = (Tree)rl;
}
}
class Tree { }
Опции:
What is the result? (Choose all that apply.)
A. An exception is thrown at runtime
B. The code compiles and runs with no output
C. Compilation fails with an error at line 8
D. Compilation fails with an error at line 9
E. Compilation fails with an error at line 12
F. Compilation fails with an error at line 13
Ответ, приведенный в книге, является A, поскольку Tre e не может быть подавлен в Redwood. У меня просто есть проблема, чтобы понять концепцию.
'go2 ((Redwood) новое дерево(), новый Redwood (]'? Опечатка? – exexzian