- 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
最近下载
- DB11T 383-2023 建筑工程施工现场安全资料管理规程.docx
- 2024-2025学年小学劳动三年级上册人教版《劳动教育》教学设计合集.docx
- 单位工伤事故认定公示情况反馈表(样表).doc
- 卫生监督法律法规和政策文件答案-2024年全国疾控系统“大学习”活动.docx VIP
- (心理咨询师习题集《案例分析》.doc VIP
- 《民航危险品运输》教学课件.docx VIP
- 拼多多新商家基础经营能力认证考试题库答案,平台规则+商品设置+客户服务+订单售后.docx
- 推动车辆互联的创新驱动车联网MNO智能物联卡平台解决方案.pptx
- 云平台解决方案酒店管理系统的完美选择.pptx
- GB50084-2017 自动喷水灭火系统设计规范.docx
文档评论(0)