当前位置:SCJP程序员认证考试题库

问题:

[单选]

1. public class Person { 
2. private String name; 
3. public Person(String name) { this.name = name; } 
4. public boolean equals(Person p) { 
5. return p.name.equals(this.name); 
6. } 
7. } 
Which is true?() 

A .  The equals method does NOT properly override the Object.equals method.
B .  Compilation fails because the private attribute p.name cannot be accessed in line 5.
C .  To work correctly with hash-based data structures, this class must also implement the hashCode method.
D .  When adding Person objects to a java.util.Set collection, the equals method in line 4 will prevent duplicates.

组装横担时,双横担左右扭斜不大于横担总长度的()。 1/1000。 1/500。 1/100。 1/50。 通报的撰写主要用下列哪种表达方式() 记叙。 议论。 说明。 说明兼议论。 危害因素识别和风险评价依据包括哪些? 单体解离是指把组成矿石的各种()相互分离。 金属。 矿物。 有用矿物。 版面布局

1. public class Person { 
2. private String name; 
3. public Person(String name) { this.name = name; } 
4. public boolean equals(Person p) { 
5. return p.name.equals(this.name); 
6. } 
7. } 
Which is true?() 

参考答案:

  参考解析

本题暂无解析

在线 客服