当前位置: 技术问答>java相关
请教大家一道scjp的继承(is a)的问题?
来源: 互联网 发布时间:2015-11-11
本文导语: Which two demonstrate an “is a” relationship? (Choose Two) A. public interface Person { } public class Employee extends Person { } B. public interface Shape { } public class Employee extends Shape { } C. public interface Color { } pu...
Which two demonstrate an “is a” relationship? (Choose Two)
A. public interface Person { }
public class Employee extends Person { }
B. public interface Shape { }
public class Employee extends Shape { }
C. public interface Color { }
public class Employee extends Color { }
D. public class Species { }
public class Animal (private Species species
E. interface Component { }
Class Container implements Component (
Private Component[ ] children;
)
为什么答案是D,E.
extends,implements都应该是is a 关系呀?此题中怎样算是has a关系呢?
A. public interface Person { }
public class Employee extends Person { }
B. public interface Shape { }
public class Employee extends Shape { }
C. public interface Color { }
public class Employee extends Color { }
D. public class Species { }
public class Animal (private Species species
E. interface Component { }
Class Container implements Component (
Private Component[ ] children;
)
为什么答案是D,E.
extends,implements都应该是is a 关系呀?此题中怎样算是has a关系呢?
|
我不清楚,没有研究过……
不过……Interface被extends之后难道不是Interface了么?
不过……Interface被extends之后难道不是Interface了么?
|
ABC语法上就错了
|
inteface 是不能被 extends 的,只能被 implements
所以 A B C 都是错的
所以 A B C 都是错的
|
可以这样写:
public interface Color { }
public interface Employee extends Color { }
public interface Color { }
public interface Employee extends Color { }
|
应该是has a关系吧