Question: The following code is intended to return only even numbers greater than 0 . If an even number greater than 0 is passed to the
The following code is intended to return only even numbers greater than If an even number greater than is passed to the method, it should return that number. If an odd number or zero is passed, it should return the next highest even number.
: public int returnEvenint number
:
: if number
:
: return number;
:
: else if number
:
: return number ;
:
: else
:
: return number ;
:
:
Java
Does the code work as intended?
Yes.
Incorrect Answer
No the mod function on line should read number to find even numbers.
No the else if on line and the else on line should just be if statements.
Correct Answer
No Zero will get returned on line and not make it to line
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
