Solved

For the Questions Below, Use the Following Recursive Method

Question 25

Multiple Choice

For the questions below, use the following recursive method.
public int question1_2(int x, int y)
{
if (x == y) return 0;
else return question1_2(x-1, y) + 1;
}
-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