CNET中国旗舰网站

ZDNet China | CNET科技资讯网 | 政府采购 | 行业网站联盟





 
标题: [讨论] SCJP考试试题解析十七
mesum
超级会员
Rank: 4



UID 321006
精华 0
积分 1811
帖子 73
威望 722
ZD币 160 元
阅读权限 90
注册 2008-4-21
状态 离线
  楼主
发表于 2008-6-19 21:25  资料  个人空间  短消息  加为好友 
开发者在线

SCJP考试试题解析十七

SCJP考试试题解析十七


我的QQ号:2535279


www.javaedu.com.cn

 Consider the following class:

  1. class Test(int i) {

  2. void test(int i) {

  3. System.out.println(“I am an int.”);

  4. }

  5. void test(String s) {

  6. System.out.println(“I am a string.”);

  7. }

  8.

  9. public static void main(String args[]) {

  10. Test t=new Test();

  11. char ch=“y”;

  12. t.test(ch);

  13. }

  14. }

  Which of the statements below is true?(Choose one.)

  A. Line 5 will not compile, because void methods cannot be overridden.

  B. Line 12 will not compile, because there is no version of test() that rakes a char argument.

  C. The code will compile but will throw an exception at line 12.

  D. The code will compile and produce the following output: I am an int.

  E. The code will compile and produce the following output: I am a String.

  解答:D

  点评:在第12行,16位长的char型变量ch在编译时会自动转化为一个32位长的int型,并在运行时传给void test(int i)方法。




顶部
热点频道推荐: C/S开发| 数据库| WEB开发| 嵌入式| 项目管理|
jwc0424
特级会员
Rank: 3Rank: 3



UID 334126
精华 0
积分 1071
帖子 202
威望 420
ZD币 219 元
阅读权限 70
注册 2008-6-13
状态 离线
  沙发
发表于 2008-6-24 10:03  资料  个人空间  短消息  加为好友 
正在学习中!!!!!!!!!








问道—回合制网游极品,在繁忙的工作之余要不要体验一下?很好玩!点此查看:  问道推广人   问道推广人   问道
顶部
热点频道推荐: C/S开发| 数据库| WEB开发| 嵌入式| 项目管理|
 



当前时区 GMT+8, 现在时间是 2009-7-5 05:55

  Powered by Discuz! 5.5.0 © 2001-2007 Comsenz Inc.
Processed in 0.056604 second(s), 4/3 queries

清除 Cookies - 联系我们 - ZDNetChina中文社区 - 无图版