0:00

Which index is the last element in a list called nums at?

使用size()获得列表大小。列表索引规则和数组索引是一致的。
4

Which of the following is a reason to use an array instead of an ArrayList?

ArrayList一般比数组会预留更多空间。
3

Which of the following is a reason to use an ArrayList instead of an array?

列表可以按需动态调整大小。
1

Which of the following is the correct way to get the first value in a list called nums?

使用get(index)来获取列表中索引对应元素,第一个元素的索引为0
4

Which of the following is the correct way to set the second value in a list called nums to 5?

使用set(index,value)来替换列表中索引对应的元素,第二个元素的索引为1
4

Which of the following is the correct way to remove the value 3 from the list nums = [5, 3, 2, 1]?

使用remove(index)来删除列表中索引对应的元素,3是第二个元素,其索引为1
3

Which of the following is the correct way to add 2 between the 1 and 3 in the following list nums = [1, 3, 4]?

使用add(index,value)来将元素插入到列表索引对应的位置,第二个元素的索引为1
4

Which of the following is false about an interface?

不能将interface实例化,只能用class来实现它。
4

What will print when the following code executes?

List<Integer> list1 = new ArrayList<Integer>();
list1.add(new Integer(1));
list1.add(new Integer(2));
list1.add(new Integer(3));
list1.remove(1);
System.out.println(list1);
删除了索引为1的第二位元素。
4

What will print when the following code executes?

List<String> list1 = new ArrayList<String>();
list1.add("Anaya");
list1.add("Layla");
list1.add("Sharrie");
list1.set(0, "Destini");
list1.add(0, "Sarah");
System.out.println(list1);
先替换第一位,再插入第一位。
1


陈 欣

AADPS创始人

发表评论