- 1、本文档共5页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 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
您可能关注的文档
- 静力学接触分析workbench.pdf
- 2 单元单词.ppt
- ASA使用NPS做RADIUS认证做IPsec VPN.pdf
- 英语写作American Food.doc
- LightTools 小面反光杯的设计.pdf
- 新编大学英语4 unit2 book4 听力原文和答案核对版.doc
- 多串口下载工具 Multiport Download Tool 使用方法V1.2-20120416.pdf
- My life closed twice before its close —by Emily Dickson.ppt
- TrueCrypt使用教程(完全详细版).doc
- LED背光的设计与优化(LightTools).pdf
最近下载
- 三到六年级的英语单词汇总.docx
- 2023年11月四川省德昌生态环境监测站招考4名就业见习人员笔试历年高频考题(难、易错点荟萃)答案带详解附后.docx
- C103116【基础】2025年东北师范大学045101教育管理《841学校组织与管理之教育管理学》.pdf VIP
- ABB 传动变频器 ACS880-04(200-600 kW)传动模块硬件手册 安装及使用手册.pdf
- (入党积极分子)思想汇报.doc VIP
- 入党积极分子(发展对象)培训班学习心得体会.docx VIP
- 物业二次装修管理培训课件.pptx
- 祭母舅的祭文.docx
- 国家开放大学电大本科《社会保障学》2024期末试题及答案(试卷号:1283).doc VIP
- 公路工程标准施工招标文件 2018年版(完整版).doc
文档评论(0)