阿摩線上測驗
登入
首頁
>
教甄◆觀光事業科/餐飲管理科
>
106年 - 106 國立高雄餐旅大學附屬餐旅高級中等學校教師徵選高中部觀光科試題卷#99331
>
題組內容
填充題
(1)
其他申論題
184. Place each Collection Type on the statement to which it applies.
#415287
188. 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)".
#415288
191. Given: 11. //insert code here 12. private N min, max; 13. public N getMin() { return min; } 14. public N getMax() { return max; } 15. public void add(N added) { 16. if(min == null || added.doubleValue() < min.doubleValue()) 17. min = added; 18. if(max == null || added.doubleValue() > max.doubleValue()) 19. max = added; 20. } 21. } Which two, inserted at line 11, will allow the code to compile? (Choose two.) (A) public class MinMax<?>{ (B) public class MinMax<? extends Number>{ (C) public class MinMax<N extends Object>{ (D) public class MinMax<N extends Number>{ (E) public class MinMax<? extends Object>{ (F) public class MinMax<N extends Integer>{
#415289
199. Given: 10. interface A{void x();} 11. class B implements A{public void x(){} public void y(){}} 12. class C extends B{public void x(){}} And: 20. java.util.List<A> list = new java.util.ArrayList<A>(); 21. list.add(new B()); 22. list.add(new C()); 23. for(A a : list){ 24. a.x(); 25. a.y(); 26. } What is the result? (A) The code runs with no output. (B) An exception is thrown at runtime. (C) Compilation fails because of an error in line 20. (D) Compilation fails because of an error in line 21. (E) Compilation fails because of an error in line 23. (F) Compilation fails because of an error in line 25.
#415290
(2)
#415292
(3)
#415293
(4)
#415294
(5)
#415295
1. Carte Du Jour
#415296
2. Food Miles
#415297