QUESTION 34자격증/OCJP_ExamD2018. 8. 5. 20:28
Table of Contents
반응형
QUESTION 34Given:1. import java.util.*;2.3. public class Explorer3 {4. public static void main(String[] args) {5. TreeSet<Integer> s = new TreeSet<Integer>();6. TreeSet<Integer> subs = new TreeSet<Integer>();7. for (int i = 606; i < 613; i++)8. if (i % 2 == 0)9. s.add(i);10. subs = (TreeSet) s.subSet(608, true, 611, true);11. subs.add(629);12. System.out.println(s + " " + subs);13. }14. }What is the result?A. Compilation fails.B. An exception is thrown at runtime.C. [608, 610, 612, 629] [608, 610]D. [608, 610, 612, 629] [608, 610, 629]E. [606, 608, 610, 612, 629] [608, 610]F. [606, 608, 610, 612, 629] [608, 610, 629]Solution : B
plus imformation
Exception in thread "main" java.lang.IllegalArgumentException: key out of range
at java.util.TreeMap$NavigableSubMap.put(TreeMap.java:1386)
at java.util.TreeSet.add(TreeSet.java:238)
at Explorer3.main(Main.java:11)
반응형
'자격증 > OCJP_ExamD' 카테고리의 다른 글
QUESTION 35 (0) | 2018.08.05 |
---|---|
QUESTION 33 (0) | 2018.08.05 |
QUESTION 32 (0) | 2018.08.05 |
QUESTION 31 (0) | 2018.08.05 |
QUESTION 30 (0) | 2018.08.05 |
@IT grow. :: IT grow.
#IT #먹방 #전자기기 #일상
#개발 #일상