Services
Discover
Homeschooling
Ask a Question
Log in
Sign up
Filters
Done
Question type:
Essay
Multiple Choice
Short Answer
True False
Matching
Topic
Computing
Study Set
Big Java Early Objects
Quiz 14: Sorting and Searching
Path 4
Access For Free
Share
All types
Filters
Study Flashcards
Practice Exam
Learn
Question 81
Multiple Choice
Complete the code shown to define the Comparator interface for comparing Auto objects.
Question 82
Multiple Choice
Which of the following statements correctly provides a comparator function using lambda expressions to sort an array of countries by population, assuming the existence of a getPopulation method?
Question 83
Multiple Choice
What must be true about the return value from the implementation of the compare method for the Comparator interface when comparing two objects, a and b with a call to compare(a, b) ?
Question 84
Multiple Choice
Suppose a developer gets class XYZ files and documentation from a subcontractor.This class does not implement the Comparable interface.What must be true in order for the developer to sort an array of XYZ objects without modifying the XYZ class?
Question 85
Multiple Choice
Which of the following classes implement the Comparable interface? i.Date II.Collections III.String
Question 86
Multiple Choice
The ____ class contains a sort method that can sort array lists.
Question 87
Multiple Choice
Suppose the call obj1.compareTo(obj2) returns 0.What can definitely be concluded from the return value? i.obj1 and obj2 are the same object II.obj1 and obj2 objects cannot be compared III.the properties of obj1 and obj2 that are being compared have equal values
Question 88
Multiple Choice
Which of the following statements correctly specifies the use of lambda expressions and the comparing method of the Comparator functional interface to sort an array of countries by population, assuming the existence of a getPopulation method?
Question 89
Multiple Choice
The binarySearch method of the Collections class returns a value in the form of -k - 1 when the target item you are searching for was not found in the array.What does k represent?
Question 90
Multiple Choice
Suppose you wish to implement the Comparable interface to allow your Vehicle class to compare Auto objects only.Which of the following is the correct way to do this?
Question 91
Multiple Choice
If a call to the Arrays static method binarySearch returns a value of 7, what can be concluded? i.the element is not in the array II.the element is at index 7 III.the element occurs 7 times in the array
Question 92
Multiple Choice
Suppose you wish to sort an array list of objects, but the object class does not implement the Comparable interface.Because you are not allowed to modify this class, you decide to provide a comparator object that implements the Comparator interface.Which method must you implement from this interface to achieve your objective?
Question 93
Multiple Choice
The Comparable interface consists of a single method called ____.
Question 94
Multiple Choice
Suppose objects a and b are from a user-defined class that implements the Comparable interface.What must be true about the return value of a.compareTo(b) for the compareTo method that this class implements?
Question 95
Multiple Choice
Given the following code snippet for searching an array:
What value will pos have when this code is executed?
Question 96
Multiple Choice
Suppose objects a and b are from a user-defined class that implements the Comparable interface.Which condition tests the compareTo method's return value to determine that a will precede b when the sort method is called?