多选题 What is the output of the following code segment?
ArrayList <String> sampleArrayList = new ArrayList <String>();
sampleArrayList.add ("One");
sampleArrayList.add ("Two");
sampleArrayList.add (1, "Three");
for(String s : sampleArrayList) {
System.out.print(s+" ");
}
  • A. One Two Three
  • B. One Three Two
  • C. Three One Two
  • D. One Three
  • E. Three Two
  • F. A compile time error will be generated.
  • G. A runtime exception will be thrown.
【正确答案】 B
【答案解析】Three字符串被插入到索引1处。因为数组的索引从0开始,索引1会将Three放置到其他两个元素中间。A、C、D、E、F和G不正确。