QUESTION 39자격증/OCJP_ExamA2018. 7. 8. 02:32
Table of Contents
반응형
QUESTION 39
Given:
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 statement 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.
Solution : A
반응형
'자격증 > OCJP_ExamA' 카테고리의 다른 글
QUESTION 41 (0) | 2018.07.08 |
---|---|
QUESTION 40 (0) | 2018.07.08 |
QUESTION 38 (0) | 2018.07.08 |
QUESTION 37 (0) | 2018.07.08 |
QUESTION 36 (0) | 2018.07.08 |
@IT grow. :: IT grow.
#IT #먹방 #전자기기 #일상
#개발 #일상