移动端

  • 题王微信公众号

    题王微信公众号

    微信搜“题王网”真题密题、最新资讯、考试攻略、轻松拿下考试

单选题

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?() 

发布日期:2020-04-10

1. public class Person {  2. private String name; ...
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.

题王网让考试变得更简单

扫码关注题王,更多免费功能准备上线!

此试题出现在

CMS专题

CMS专题

去刷题
热门试题热门资讯 相关试题

暂无相关推荐~