zming
发贴: 21
积分: 1
|
于 2004-04-14 12:06
Consider the class hierarchy shown below: Animal | Mammal / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ Dog Cat Raccoon SwampThing (implements) (implements) ( Washer ) ( Washer )
Consider the following code: 1. Cat sunflower; 2. Washer wawa; 3. SwampThing pogo; 4. 5. sunflower = new Cat(); 6. wawa = sunflower; 7. pogo = (SwampThing)wawa;
Which of the statements below is true?
第7行为什么是运行时错误,而不是编译错误。 pogo = (SwampThing)wawa; 其中wawa是Washer类型和Animal~ SwampThing的层次一点关系也没有,居然不是编译错误。
|