欢迎来到求知题库网 求知题库官网
logo
全部科目 > Java认证考试 > SCJP程序员认证考试

单项选择题

public class Person { 
private name; 
public Person(String name) { 
this.name = name; 
} 
public boolean equals(Object o) { 
if( !o instanceof Person ) return false; 
Person p = (Person) o; 
return p.name.equals(this.name); 
} 
} 
Which is true?() 

    A. Compilation fails because the hashCode method is not overridden.
    B. A HashSet could contain multiple Person objects with the same name.
    C. All Person objects will have the same hash code because the hashCode method is not overridden.
    D. If a HashSet contains more than one Person object with name=”Fred”, then removing another person, also with name=”Fred”, will remove them all.

点击查看答案&解析

相关考题

微信小程序免费搜题
微信扫一扫,加关注免费搜题

微信扫一扫,加关注免费搜题

微信扫一扫,加关注免费搜题

微信扫一扫,加关注免费搜题