请教大家!

dulang200x 2003-10-20 02:41:27
Q50
Given the following interface definition, which definitions are valid?

interface I {
void setValue(int val);
int getValue();
}

DEFINITION A:
(a) class A extends I {
int value;
void setValue(int val) { value = val; }
int getValue() { return value; }
}

DEFINITION B:
(b) interface B extends I {
void increment();
}

DEFINITION C:
(c) abstract class C implements I {
int getValue() { return 0; }
abstract void increment();
}

DEFINITION D:
(d) interface D implements I {
void increment();
}

DEFINITION E:
(e) class E implements I {
int value;
public void setValue(int val) { value = val; }
}

1) Definition A.
2) Definition B.
3) Definition C.
4) Definition D.
5) Definition E.
答案是2,3
我认为是1,2,3
Definition A中,A继承了B,且把B中的所有abstract都实现了,不是对的吗?
...全文
59 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
BenLLLL 2003-10-20
  • 打赏
  • 举报
回复
a中的class 不能extends 接口,要implements

dulang200x 2003-10-20
  • 打赏
  • 举报
回复
Q51
Which statements concerning the methods notify() and notifyAll() are true?

1) Instances of class Thread have a method called notify().
2) A call to the method notify() will wake the thread that currently owns the monitor of the object.
3) The method notify() is synchronized.
4) The method notifyAll() is defined in class Thread.
5) When there is more than one thread waiting to obtain the monitor of an object, there is no way to be sure which thread will be notified by the notify() method.

不好意思,还有一题!我认为选1,2,3,5
答案是1,5
请帮忙解释下,2,3 为什么不对?

50,523

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧