Solved

Consider the Code for the Recursive Method MysteryPrint Shown in This

Question 7

Multiple Choice

Consider the code for the recursive method mysteryPrint shown in this code snippet:
Public static int mysteryPrint(int n)
{
If (n == 0)
{
Return 0;
}
Else
{
Return (n + mysteryPrint(n-1) ) ;
}
}
What will be printed with a call to mysteryPrint(-4) ?


A) 0
B) -10
C) -22
D) Nothing - a StackoverflowError exception will occur

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