| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 755 人关注过本帖
标题:帮忙看一下
取消只看楼主 加入收藏
pine
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2004-8-10
收藏
 问题点数:0 回复次数:1 
帮忙看一下

1. public class Test2 extends MyBase implements MyInterface { int x = 0; 5. public Test2(int inVal) throws Exception { 7. if( inVal != this.x) { 9. throw new Exception("Invalid input"); } } public static void main(String[] args) { 15. Test2 t = new Test2(4); } }

A.the code fails to compile at line1. it's not valid to both implement an interface and extends from a parent class simultaneously.

B.the code fails to compile at line 5.int's not valid for constructors to throw exceptions.

C.the code fails to compile at line9,because this is not valid way to throw an exception.

D.the code fails to compile at line15.the compiler complains that there is an uncaught exception.

E.the code fails to compile at line7,because this is not a valid way to reference variable x.

答案是D,可是我选了A,大家帮帮忙看一下,如果选D帮忙解释一下,谢谢了

搜索更多相关主题的帖子: class void interface public parent 
2004-08-16 13:25
pine
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2004-8-10
收藏
得分:0 

哦。明白了~~我真是笨啊~呵呵,谢谢了~~非常感谢~~~

2004-08-17 13:22
快速回复:帮忙看一下
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014694 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved