2009年2月24日 星期二

第192題

Given:
3. import java.util.*;
4. public class G1{
5. public void takeList(List list){
6. //insert code here
7. }
8. }

Which three code fragments, inserted independently at line 6, will compile? (Choose three.)

A. list.add("foo");
B. Object o = list;
C. String s = list.get(0);
D. list = new ArrayList(string)();
E. list = new ArrayList(object)();
答案:BCD
參考:7-8 物件的轉型、12-3 泛型

1 則留言: