SCJP 1.6版考題 026
出自 陳富國維基館
10. interface Jumper{public void jump();} ... 20. class Animal{} ... 30. class Dog extends Animal{ 31. Tail tail; 32. } ... 40. class Beagle extends Dog implements Jumper{ 41. public void jump(){} 42. } ... 50. class Cat implements Jumper{ 51. public void jump(){} 52. } Which three are true? (Choose three.) A. Cat is-a Animal B. Cat is-a Jumper C. Dog is-a Animal D. Dog is-a Jumper E. Cat has-a Animal F. Beagle has-a Tail G. Beagle has-a Jumper
解答
Ans: B C F
解說:
extends擴充,即是繼承後擴充的意思 (C) implements是實作介面,也是另一種繼承,只是將介面中所制定的各種規格一一實作出來,具備介面制定的能力!(B) Beagle 繼承Dog,而Dog類別has-a Tail,因此Beagle 也有Tail (F)
|