QUESTION 41자격증/OCJP_ExamA2018. 7. 8. 02:53
Table of Contents
반응형
QUESTION 41
Given a pre-generics implementation of a method:
11. public static int sum(List list) {
12. int sum = 0;
13. for ( Iterator iter = list.iterator(); iter.hasNext(); ) {
14. int i = ((Integer)iter.next()).intValue();
15. sum += i;
16. }
17. return sum;
18. }
What three changes allow the class to be used with generics and avoid an unchecked warning? (Choose three.)
A. Remove line 14.
B. Replace line 14 with int i = iter.next();
C. Replace line 13 with for (int i : intList) {
D. Replace line 13 with for (Iterator iter : intList) {
E. Replace the method declaration with sum(List<int> intList)
F. Replace the method declaration with sum(List<Integer> intList)
Solution : ACF
반응형
'자격증 > OCJP_ExamA' 카테고리의 다른 글
QUESTION 43 (0) | 2018.07.08 |
---|---|
QUESTION 42 (0) | 2018.07.08 |
QUESTION 40 (0) | 2018.07.08 |
QUESTION 39 (0) | 2018.07.08 |
QUESTION 38 (0) | 2018.07.08 |
@IT grow. :: IT grow.
#IT #먹방 #전자기기 #일상
#개발 #일상