Multiple Choice 1. A programmer wishes to use the binarySeach method to search f
ID: 3795437 • Letter: M
Question
Multiple Choice
1. A programmer wishes to use the binarySeach method to search for specific objects
contained in a LinkedList. Which method should the programmer use?
a. Collections.binarySearch
b. Arrays.binarySearch
c. The Java API does not define an appropriate searching method - the programmer must
write her/his own method
2. A programmer wishes to sort an array of objects. The objects are instances of a class that
defines several instance fields. Different situations may require ordering the array by
different fields (i.e., the program may require several sort orders). Which ordering
technique should the programmer use?
a. Comparable interface
b. Comparator interface
c. Arrays.sort
d. Collections.sort
3. Examine the following interface, class, and object instantiation.
public interface Foo
{
public void method();
}
public class Bar implements Foo
{
public void method()
{
. . .
}
public void someStuff()
{
. . .
}
}
------------------------------------
Foo f = new Bar();
Check all valid method calls.
a. f.method();
b. f.someStuff();
Explanation / Answer
1. A programmer wishes to use the binarySeach method to search for specific objects
contained in a LinkedList. Which method should the programmer use?
a. Collections.binarySearch
2. A programmer wishes to sort an array of objects. The objects are instances of a class that
defines several instance fields. Different situations may require ordering the array by
different fields (i.e., the program may require several sort orders). Which ordering
technique should the programmer use?
b. Comparator interface
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.