网站大量收购闲置独家精品文档,联系QQ:2885784924

Java语言程序设计课后习题答案英文版.doc

  1. 1、本文档共35页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Java语言程序设计课后习题答案英文版

Chapter 2 Primitive Data Types and Operations 1. Valid identifiers: applet, Applet, $4, appsInvalid identifiers: a++, --a, 4#R, #44 2. Keywords: class, public, int 3. double miles = 100; final double MILE_TO_KILOMETER = 1.609; double kilometer = MILE_TO_KILOMETER * miles; System.out.println(kilometer); The value of kilometer is 160.9. 4. There are three benefits of using constants: (1)you don’t have to repeatedly type the same value; (2)the value can be changed in a single location, ifnecessary; (3) the program is easy to read. final int SIZE = 20; 5. a = 46 / 9; = a = 5 a = 46 % 9 + 4 * 4 - 2; = a = 1 + 16 – 2 = 15 a = 45 + 43 % 5 * (23 * 3 % 2); = a = 45 + 3 * (1) = 48 a %= 3 / a + 3; = a %= 3 + 3; a % = 6 = a = a % 6 = 1; d = 4 + d * d + 4; = 4 + 1.0 + 4 = 9.0 d += 1.5 * 3 + (++a); = d += 4.5 + 2; d += 6.5; = d = 7.5 d -= 1.5 * 3 + a++; = d -= 4.5 + 1; = d = 1 – 5.5 = -4.5 6. 2 2 -4 -4 0 1 7. For byte, from -128 to 127, inclusive. For short, from -32768 to 32767, inclusive. For int, from -2147483648 to 2147483647, inclusive. For long, from -9223372036854775808 to9223372036854775807. For float, the smallest positive float is1.40129846432481707e-45 and the largest float is3.40282346638528860e+38. For double, the smallest positive double is4.94065645841246544e-324 and the largest double is1.79769313486231570e+308d. 8. 25/4= 6. If you want the quotient to be a floating-point number, rewrite it as 25.0/4.0. 9. Yes, the statements are correct. The printout is the output for 25 / 4 is 6; the output for 25 / 4.0 is 6.25; 10. 4.0 / (3.0 * (r + 34)) – 9 * (a + b * c) + (3.0 + d * (2 + a)) / (a + b * d) 11. b and c are true. 12. All. 13. Line 2: Missing static for the main method. Line 2: string should be String. Line 3: i is defined but not initialized before it is used in Line 5. Line 4: k is an int, cannot assign a double value to k. Lines 7-8: The string cannot be broken into two lines. 14. Yes. Different types of numeric valu

文档评论(0)

pangzilva + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档