Autigers.org These questions are from the Exam One of COMP2210-Sp2017 Course at
ID: 3824385 • 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
I re-upload it as follow
The max method below is intended to return the largest value in the parameter coll. Which test case parameter would expose the logic error in this method? public static T extends Comparable T>> T max (Collection KT coll Iterator T> itr coll iterator itr next T max while (itr hasNext O) t if (max. compareTo itr next 0) t max itr next return max; A. Coll C1, 3, 5, 7, 9] B. Coll (19, 7, 5, 3, 11 C. coll C3, 7, 9, 1, 5] D. Coll C1, 9, 3, 7, 5]Explanation / Answer
Question 1:
Answer: D. col1 = [1, 9, 3, 7, 5]
In this case, As per logic it will return max value as 5 which is wrong.
Question 2:
Answer: D x.eqauls(y) == false
x.compareTo(y) value is 1 means x and y are not same. if both are same then x.compareTo(y) will return 0.
So D option is the correct answer to say both are not same.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.