AP计算机教程7-7:简单多选题
0:00
Which index is the last element in a list called nums
at?
size()
获得列表大小。列表索引规则和数组索引是一致的。Which of the following is a reason to use an array instead of an ArrayList
?
ArrayList
一般比数组会预留更多空间。Which of the following is a reason to use an ArrayList
instead of an array?
Which of the following is the correct way to get the first value in a list called nums
?
get(index)
来获取列表中索引对应元素,第一个元素的索引为0
。Which of the following is the correct way to set the second value in a list called nums
to 5?
set(index,value)
来替换列表中索引对应的元素,第二个元素的索引为1
。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
。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
。Which of the following is false about an interface?
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
的第二位元素。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);
0 条评论