Given: ArrayList a = new ArrayList(); containing the values {“1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”} Which code will return 2?() A、 Collections. sort(a, a.reverse()); int result = Collections.binarySearch(a, “6”);B、 Comparator c = Collections.reverseOrder(); Collections.sort(a, c); int result = Collections.binarySearch(a, “6”);C、 Comparator c = Collections.reverseOrder(); Collections.sort(a, c); int result = Collections.binarySearch(a, “6”,c);D、 Comparator c = Collections.reverseOrder(a); Collections.sort(a, c); int result = Collections.binarySearch(a, “6”,c);E、 Comparator c = new InverseComparator(new Comparator()); Collections.sort(a); int result = Collections.binarySearch(a, “6”,c);
Given: ArrayList a = new ArrayList(); containing the values {“1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”} Which code will return 2?()
- A、 Collections. sort(a, a.reverse()); int result = Collections.binarySearch(a, “6”);
- B、 Comparator c = Collections.reverseOrder(); Collections.sort(a, c); int result = Collections.binarySearch(a, “6”);
- C、 Comparator c = Collections.reverseOrder(); Collections.sort(a, c); int result = Collections.binarySearch(a, “6”,c);
- D、 Comparator c = Collections.reverseOrder(a); Collections.sort(a, c); int result = Collections.binarySearch(a, “6”,c);
- E、 Comparator c = new InverseComparator(new Comparator()); Collections.sort(a); int result = Collections.binarySearch(a, “6”,c);
相关考题:
欲构造ArrayList类的一个实例,此类继承了List接口,下列哪个方法是正确的?( B ) A.ArrayList myList=new Object();B.List myList=new ArrayList();C.ArrayList myList=new List();D.List myList=new List();
欲构造ArrayList类的一个实例,此类实现List接口,下列方法正确的是______。A.ArrayList myList=new Object( );B.List myList=new ArrayList( );C.ArrayList myList=new List( );D.List myList=new List( );
欲构造ArrayList类的一个实例,此类继承了List接口,下列( )方法是正确的。A.ArrayList myList=new Object();B.List myList=new ArrayList();C.ArrayList myList=new List();D.List myList=new List();
YouarewritingaJSPthatincludesscriptletcodetodeclareaListvariableandinitializesthatvariabletoanArrayListobject.WhichtwoJSPcodesnippetscanyouusetoimporttheselisttypes?() A.%!importjava.util.*;%B.%!importjava.util.List;importjava.util.ArrayList;%C.%@pageimport=’java.util.List’import=’java.util.ArrayList’%D.%@importtypes=’java.util.List’types=’java.util.ArrayList’%E.%@pageimport=’java.util.List,java.util.ArrayList’%F.%@importtypes=’java.util.List,java.util.ArrayList’%
欲构造ArrayList类的一个实例,此类继承了List接口,下列( )是正确的。A.ArrayListmyList=new Object();B.List myList=new ArrayList();C.ArrayList myList=new List();D.List myList=new List();
Given: int[] myArray=newint[] {1, 2,3,4, 5}; What allows you to create a list from this array?() A、 List myList = myArray.asList();B、 List myList = Arrays.asList(myArray);C、 List myList = new ArrayList(myArray);D、 List myList = Collections.fromArray(myArray);
Vector和ArrayList的主要区别是()A、ArrayList内部基于链表,而Vector是基于数组的B、Vector的大部分方法做了同步,而ArrayList没有同步C、Vector是可串行化的,而ArrayList不是D、Vector实现了RandomAccess,而ArrayList没有
You are writing a JSP that includes scriptlet code to declare a List variable and initializes that variable to anArrayList object. Which two JSP code snippets can you use to import these list types?()A、%! import java.util.*; %B、%! import java.util.List;import java.util.ArrayList; %C、%@ page import=’java.util.List’import=’java.util.ArrayList’ %D、%@ import types=’java.util.List’types=’java.util.ArrayList’ %E、%@ page import=’java.util.List,java.util.ArrayList’ %F、%@ import types=’java.util.List,java.util.ArrayList’ %
ArrayList和LinkList的描述,下面说法错误的是()。A、LinkedeList和ArrayList都实现了List接口B、ArrayList是可改变大小的数组,而LinkedList是双向链接串列C、LinkedList不支持高效的随机元素访问D、在LinkedList的中间插入或删除一个元素意味着这个列表中剩余的元素都会被移动;而在ArrayList的中间插入或删除一个元素的开销是固定的
Vector 与 ArrayList正确的是:()A、 ArrayList 出现比Vector早B、 ArrayList 速度比Vector慢C、 ArrayList 没有同步保护,Vector具有同步保护D、 ArrayList Vector 两者都是无序的集合"
创建一个ArrayList集合实例,该集合中只能存放String类型数据,下列()代码是正确的A、ArrayList myList=new ArrayList()B、ArrayListStringmyList=new ArrayList;()C、ArrayListmyList=new ArrayListString()D、ArrayListmyList=new List()
欲构造ArrayList类的一个实例,此类继承了List接口,下列哪个方法是正确的?()A、 ArrayList myList=new Object();B、 List myList=new ArrayList();C、 ArrayList myList=new List();D、 List myList=new List();
在JAVA中,LinkedList类和ArrayList类同属于集合框架类,下列()选项中的方法是LinkedList类有而ArrayList类没有的。A、add(Objecto)B、add(intndex,Objecto)C、remove(Objecto)D、removeLast()
单选题创建一个ArrayList集合实例,该集合中只能存放String类型数据,下列()代码是正确的AArrayList myList=new ArrayList()BArrayListStringmyList=new ArrayList;()CArrayListmyList=new ArrayListString()DArrayListmyList=new List()
单选题Given: int[] myArray=newint[] {1, 2,3,4, 5}; What allows you to create a list from this array?()A List myList = myArray.asList();B List myList = Arrays.asList(myArray);C List myList = new ArrayList(myArray);D List myList = Collections.fromArray(myArray);
单选题Given: 11. public void genNumbers() { 12. ArrayList numbers = new ArrayList(); 13. for (int i=0; i10; i++) { 14. int value = i * ((int) Math.random()); 15. Integer intObj = new Integer(value); 16. numbers.add(intObj); 17. } 18. System.out.println(numbers); 19. } Which line of code marks the earliest point that an object referenced by intObj becomes a candidate for garbage collection?()A Line 19B The object is NOT a candidate for garbage collection.C Line 17D Line 16E Line 18
单选题1. import java.util.*; 2. class SubGen { 3. public static void main(String [] args) { 4. //insert code here 5. } 6. } class Alpha { } class Beta extends Alpha { } class Gamma extends Beta { } 和四段代码片段: s1. ArrayList〈? extends Alpha〉 list1 = new ArrayList〈Gamma〉(); s2. ArrayList〈Alpha〉 list2 = new ArrayList〈? extends Alpha〉(); s3. ArrayList〈? extends Alpha〉 list3 = new ArrayList〈? extends Beta〉(); s4. ArrayList〈? extends Beta〉 list4 = new ArrayList〈Gamma〉(); ArrayList〈? extends Alpha〉 list5 = list4; 哪些片段分别插入到第4行,可允许代码编译?()A只有s1B只有s3C只有s1和s3D只有s1和s4
多选题You are writing a JSP that includes scriptlet code to declare a List variable and initializes that variable to anArrayList object. Which two JSP code snippets can you use to import these list types?()A%! import java.util.*; %B%! import java.util.List;import java.util.ArrayList; %C%@ page import=’java.util.List’import=’java.util.ArrayList’ %D%@ import types=’java.util.List’types=’java.util.ArrayList’ %E%@ page import=’java.util.List,java.util.ArrayList’ %F%@ import types=’java.util.List,java.util.ArrayList’ %
单选题Given: ArrayList a = new ArrayList(); containing the values {“1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”} Which code will return 2?()A Collections. sort(a, a.reverse()); int result = Collections.binarySearch(a, “6”);B Comparator c = Collections.reverseOrder(); Collections.sort(a, c); int result = Collections.binarySearch(a, “6”);C Comparator c = Collections.reverseOrder(); Collections.sort(a, c); int result = Collections.binarySearch(a, “6”,c);D Comparator c = Collections.reverseOrder(a); Collections.sort(a, c); int result = Collections.binarySearch(a, “6”,c);E Comparator c = new InverseComparator(new Comparator()); Collections.sort(a); int result = Collections.binarySearch(a, “6”,c);
单选题Vector和ArrayList的主要区别是()AArrayList内部基于链表,而Vector是基于数组的BVector的大部分方法做了同步,而ArrayList没有同步CVector是可串行化的,而ArrayList不是DVector实现了RandomAccess,而ArrayList没有
单选题欲构造ArrayList类的一个实例,此类继承了List接口,下列哪个方法是正确的?()AArrayList myList=new Object();BList myList=new ArrayList();CArrayList myList=new List();DList myList=new List();
单选题Vector 与 ArrayList正确的是:()A ArrayList 出现比Vector早B ArrayList 速度比Vector慢C ArrayList 没有同步保护,Vector具有同步保护D ArrayList Vector 两者都是无序的集合