java笔试题07.doc

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

1. Given the following, 11. x = 0; 12. if (x1.hashCode() != x2.hashCode() ) x = x + 1; 13. if (x3.equals(x4) ) x = x + 10; 14. if (!x5.equals(x6) ) x = x + 100; 15. if (x7.hashCode() == x8.hashCode() ) x = x + 1000; 16. System.out.println(x = + x); and assuming that the equals () and hashCode() methods are property implemented, if the output is “x = 1111”, which of the following statements will always be true? A. x2.equals(x1) B. x3.hashCode() == x4.hashCode() C. x5.hashCode() != x6.hashCode() D. x8.equals(x7) 2. Given the following, class Test1 { public int value; public int hashCode() { return 42; } } class Test2 { public int value; public int hashcode() { return (int)(value^5); } } which statement is true? A. class Test1 will not compile. B. The Test1 hashCode() method is more efficient than the Test2 hashCode() method. C. The Test1 hashCode() method is less efficient than the Test2 hashCode() method. D. class Test2 will not compile. E. The two hashcode() methods will have the same efficiency. 3. Which two statements are true about comparing two instances of the same class, given that the equals() and hashCode() methods have been properly overridden? (Choose two.) A. If the equals() method returns true, the hashCode() comparison == must return true. B. If the equals() method returns false, the hashCode() comparison != must return true. C. If the hashCode() comparison == returns true, the equals() method must return true. D. If the hashCode() comparison == returns true, the equals() method might return true. E. If the hashCode() comparison != returns true, the equals() method might return true. 4. Which class does not override the equals() and hashCode() methods, inheriting them directly from class Object? A. java.lang.String B. java.lang.Double C. java.lang.StringBuffer D. java.lang.Character E. java.util.ArrayList 5. What two statements are true about properly overridden hashCode() and equals() methods? A. hashCode() doesn’t have to be overridden if equals() is

文档评论(0)

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

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

1亿VIP精品文档

相关文档