Solved

Consider the Code for the Recursive Method MyPrint Shown in This

Question 16

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

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents