Oracle
1Z0-851 · Question #216
1Z0-851 Question #216: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-851 to reveal the answer and full explanation for question #216. The question stem and answer options stay visible for context.
Question
Given: public class Person { private String 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 statement is true?
Options
- ACompilation fails because the hashCode method is not overridden.
- BA HashSet could contain multiple Person objects with the same name.
- CAll Person objects will have the same hash code because the hashCode method is not overridden.
- DIf a HashSet contains more than one Person object with name="Fred", then removing another Person,
Unlock 1Z0-851 to see the answer
You've previewed enough free 1Z0-851 questions. Unlock 1Z0-851 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.