试题详情
单项选择题 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);

  • C
  • 关注下方微信公众号,在线模考后查看

热门试题