Solved

Consider the Code for the Recursive Method MyPrint Shown in This

Question 75

Multiple Choice

Consider the code for the recursive method myPrint shown in this code snippet: public static int myPrint(int n)
{
If (n == 0)
{
Return 0;
{
Else
{
Return (n + myPrint(n - 1) ) ;
}
}
To avoid infinite recursion, which of the following lines of code should replace the current terminating case?


A) if (n == -1)
B) if (n <= 0)
C) if (n >= 0)
D) The terminating case as shown will avoid infinite recursion.

Correct Answer:

verifed

Verified

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

Related Questions