Hi , The Class Cat and Javier has no relation with one another ,
an reference can be of its own type or its Parent type ,,,,,,,,,, not like it can't be refer to the other childs of the Parent.........
parent - > child1 parent - > child2
so it can be like d is not a refernce of the Cat......... since it doesnt what is it.......has no relation between the classes of the same heriarchy......
since only Parent - child relations only makes some meaning........
try extending the class Javier extends Cat { }
Javier Sanchez Cerrillo
Ranch Hand
Joined: Aug 02, 2006
Posts: 152
posted
0
It doesn't aswer why i can compile with Runnable and not with cat.
how "System.out.println(d instanceof Runnable);" works class Javier extends Object but neither Object nor Javier class does implements runnable interface so where this interface is implemented.
so the conclusion would be... if your check whether a particullar object is an instance of an interface, there is no way of checking whether they're in the same hieratchy at compile time rite? but this has to be detected at run time. because
at compile time a is an A but at runtime a would be a D therefore at runtime it realises that its in the same hierarchy and the condition is true...