잘난놈되기/SCJP
Q010. HashSet
whatwant
2008. 3. 30. 22:49
Question 10
Given:
11. public class Person {
12. private name;
13. public Person(String name) {
14. this.name = name;
15. }
16. public int hashCode() {
17. return 420;
18. }
19. }
Which is true?
A. The time to find the value from HashMap with a Person key depends on the size of the map.
B. Deleting a Person key from a HashMap will delete all map entries for all keys of type Person.
C. Inserting a second Person object into a HashSet will cause the first Person object to be removed as a duplicate.
D. The time to determine whether a Person object is contained in a HashSet is constant and does NOT depend on the size of the map.
[HeadFirst Java - p.567]
# HashMap : 원소들을 이름/값 쌍 형식으로 저장하고 접근할 수 있게 해줍니다.
# HashSet : 컬렉션에 중복된 원소가 들어가지 않도록 해주고, 컬렉션 내에서 어떤 원소를 빠르게 찾을 수 있게 해줍니다.
# LinkedHashMap : 일반 HashMap과 거의 똑같지만 원소(이름/값 쌍)가 삽입된 순서를 그대로 유지시켜줄 수도 있고, 원소에 마지막으로 접근했던 순서를 기억하도록 설정할 수도 있다는 점이 다릅니다.
[HeadFirst Java - p.593]
...
Answer: A
Given:
11. public class Person {
12. private name;
13. public Person(String name) {
14. this.name = name;
15. }
16. public int hashCode() {
17. return 420;
18. }
19. }
Which is true?
A. The time to find the value from HashMap with a Person key depends on the size of the map.
B. Deleting a Person key from a HashMap will delete all map entries for all keys of type Person.
C. Inserting a second Person object into a HashSet will cause the first Person object to be removed as a duplicate.
D. The time to determine whether a Person object is contained in a HashSet is constant and does NOT depend on the size of the map.
[HeadFirst Java - p.567]
# HashMap : 원소들을 이름/값 쌍 형식으로 저장하고 접근할 수 있게 해줍니다.
# HashSet : 컬렉션에 중복된 원소가 들어가지 않도록 해주고, 컬렉션 내에서 어떤 원소를 빠르게 찾을 수 있게 해줍니다.
# LinkedHashMap : 일반 HashMap과 거의 똑같지만 원소(이름/값 쌍)가 삽입된 순서를 그대로 유지시켜줄 수도 있고, 원소에 마지막으로 접근했던 순서를 기억하도록 설정할 수도 있다는 점이 다릅니다.
[HeadFirst Java - p.593]
...
Answer: A
반응형