Solved

The Following Method Should Return True If the Int Parameter

Question 11

Multiple Choice

The following method should return true if the int parameter is even and either positive or 0, and false otherwise. Which set of code should you use to replace ... so that the method works appropriately? public boolean question3(int x) { ... }


A) if (x == 0) return true;
Else if (x < 0) return false;
Else return question3(x - 1) ;
B) if (x == 0) return false;
Else if (x < 0) return true;
Else return question3(x - 1) ;
C) if (x == 0) return true;
Else if (x < 0) return false;
Else return question3(x - 2) ;
D) if (x == 0) return false;
Else if (x < 0) return true;
Else return question3(x - 2) ;
E) return(x == 0) ;

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions