Autigers.org These questions are from the Exam One of COMP2210-Sp2017 Course at
ID: 3824396 • Letter: A
Question
Autigers.org These questions are from the Exam One of COMP2210-Sp2017 Course at Auburn University. Please Answer them and give a short explanation if necessary. Thanks. www.yifanzhang.cn
Suppose x, y, and z are mutually comparable objects such that x y z. That is, x precedes y in total order, and y precedes z in total order. Assume that comp is a Comparator that defines this total order such that comp.compare(x, y) evaluates to -6 and comp compare (y, z evaluates to -3. According to the specification of compare in the Comparator interface, which one of the following must be true? A. x compareTo (z) 0 B. comp Compare (x, z) -9 C. comp Compare (z, x) 0 D. Comp. Compare (x, z) 0Explanation / Answer
Question 1:
Answer: comp.compareTo(x, z) == -9
comp.compareTo(x, y) value is -6 and comp.compareTo(y, z) value is -3. So when we compare betweeen x and y comp.compareTo(x, z) will return value -9
Question 2:
Answer:
B. c is an instance of some class that implements the Collection interface.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.