CNET中国旗舰网站

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





 
标题: [转贴] Which of the following fragments might cause errors?
mesum
超级会员
Rank: 4



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

Which of the following fragments might cause errors?

Which of the following fragments might cause errors?
  A. String s = "Gone with the wind";
  String t = " good ";
  String k = s + t;
  B. String s = "Gone with the wind";
  String t;
  t = s[3] + "one";
  C. String s = "Gone with the wind";
  String standard = s.toUpperCase();
  D. String s = "home directory";
  String t = s - "directory";
  翻译下面的哪些程序片断可能导致错误。
  答案 B,D
  解析
  A:String类型可以直接使用+进行连接运算。
  B:String是一种Object,而不是简单的字符数组,不能使用下标运算符取其值的某个元素,错误。
  C:toUpperCase()方法是String对象的一个方法,作用是将字符串的内容全部转换为大写并返回转换后的结果(String类型)。
  D:String类型不能进行减(-)运算,错误。




顶部
热点频道推荐: C/S开发| 数据库| WEB开发| 嵌入式| 项目管理|
 



当前时区 GMT+8, 现在时间是 2008-11-21 23:12

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

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