考试网 >> IT认证 >> JAVA >> JAVA题库 >> 格林模拟试题三参考答案

格林模拟试题三参考答案

发布时间:2006-06-28 10:52     点击:
分页:[1] 2 3 4 5 6 7 8 9 10  下一页  后10页



Answers

Answer to Question 1)

1) float f=1/3;

2) int i=1/3;

4) double d=999d;

The fact that option 3 does not compile may be a surprise. The problem is because the default type for a number with a decimal component is a double and not a float. The additional trailing d in the option with 999 doesn't help, but it doesn't harm.


Answer to Question 2)

2) new

The option NULL (note the upper case letter) is definitely not a keyword. There is some discussion as to i. There is some discussion as to if null is a keyword but for the purpose of the exam you should probably assume it is a keyword.

The option instanceOf is a bit of a misleading option that would probably not occur on the exam. The real keyword is instanceof (note that the of has no capital letter O). I had the incorrect version in an earlier version of this tutorial as it looks more likely to my eyes. The instanceof keyword looks like a method, but it is actually an operator.

The option wend is probably valid in some other language to indicate the end of a while loop, but Java has no such keyword.


Answer to Question 3)

1) System.out.println(1+1);

2) int i=2+'2';

Option 3 is not valid because single quotes are used to indicate a character constant and not a string. Several people have emailed me to say that option 3 will compile. When they eventually compiled the exact code they have agreed, it will not compile. Let me re-state that

String s="on"+'one';

分页:[1] 2 3 4 5 6 7 8 9 10  下一页  后10页
版权申明:未经书面授权请勿转载本站信息!!作品版权归所属媒体与作者所有!!
发表评论: 匿名发表 用户名: 查看评论
您将承担一切因您的行为、言论而直接或间接导致的民事或刑事法律责任
留言板管理人员有权保留或删除其管辖留言中的任意内容
本站提醒:不要进行人身攻击。谢谢配合。
在本站搜索相关信息
2003-2005 Ksw123.com All Rights Reserved. - TOP
Copyright © 2006 Ksw123.com. All rights reserved.中国考题网 版权所有