Consider the following method checking whether a student has passing grades:

public boolean isPassing(int finalExam, int cumulativeAverage) {
/* Missing Code */
}
A student can pass a class if one of the following is true:

The final exam is at least 98
The cumulative average is over 60
Which of the following correctly replaces /* Missing Code */ so that the method works as intended?

I.

if ((finalExam >= 98) || (cumulativeAverage > 60))
return true;
return false;
II.

boolean pass = false;
if (finalExam >= 98)
pass = true;
if (cumulativeAverage > 60)
pass = true;
return pass;
III.

if (finalExam >= 98 && cumulativeAverage >= 60)
return true;
return false;
1. I only
2. II only
3. I and II only
4. II and III only
5. III only

Respuesta :

W0lf93
I did not intend to accept this question: However, I think that answer #1 is the correct answer. Option I. seems to say that the code returns True when either the Final Exam >= 98 or the cumulative average > 60. Otherwise the code returns False. I don't like option II because the code returns only true. It does not specify any reason to return a false value. I don't like the option III because of the "&&" in it. I haven't see any code that uses two "&'s back to back. That leaves only option I as being correct, and answer #1 as being the correct answer.
ACCESS MORE