Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Autigers.org These questions are from the Exam One of COMP2210-Sp2017 Course at

ID: 3824340 • 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

The min method below is intended to return the smallest of its three int pa- rameters. Which call below would expose the logic error in this method? public static int min int a, int b, int c) t if (a b) && Ca c)) return a if (b K a) && (b c) return b return C; A. min (0, 0, 0) B. min (1, 0, -1) C. min (2, 2, 4) D. min (4, 2 2)

Explanation / Answer

Solution:-

In the given method the call in option C, min (2,2,4) will expose a logic error. As we know we are using logical AND (&&) operation using here, it will return the value if both conditions are true.

For Option A. min (2,2,4) this method will return 0 as the smallest integer. All parameters are 0 and returned value is 0. So this in not logical error.

For Option B.  min (1,0,-1) this method will return -1 as the smallest integer.The returned value is -1 which is correct. So this in not logical error.

For Option C.  min (2,2,4) this method will return 4 as the smallest integer.The returned value is 4 which is incorrect. So this in a logical error.

For Option BD.  min (4,2,2) this method will return 2 as the smallest integer.The returned value is 2 as there are two same parameters both are smallest. So this in not logical error.

SO the correct answer is Opthion C min (2,2,4).