QUESTION 6자격증/OCJP_ExamB2018. 7. 9. 15:05
Table of Contents
반응형
QUESTION 6
Given:
1. import java.util.*;
2. public class WrappedString {
3. private String s;
4. public WrappedString(String s) { this.s = s; }
5. public static void main(String[] args) {
6. HashSet<Object> hs = new HashSet<Object>();
7. WrappedString ws1 = new WrappedString("aardvark");
8. WrappedString ws2 = new WrappedString("aardvark");
9. String s1 = new String("aardvark");
10. String s2 = new String("aardvark");
11. hs.add(ws1); hs.add(ws2); hs.add(s1); hs.add(s2);
12. System.out.println(hs.size()); } }
What is the result?
A. 0
B. 1
C. 2
D. 3
E. 4
F. Compilation fails. G. An exception is thrown at runtime.
Solution : D
반응형
'자격증 > OCJP_ExamB' 카테고리의 다른 글
QUESTION 8 (0) | 2018.07.09 |
---|---|
QUESTION 7 (0) | 2018.07.09 |
QUESTION 5 (0) | 2018.07.09 |
QUESTION 4 (0) | 2018.07.09 |
QUESTION 3 (0) | 2018.07.09 |
@IT grow. :: IT grow.
#IT #먹방 #전자기기 #일상
#개발 #일상