Solved

Given the Following Class Code: Public Class RecurseSample

Question 8

Multiple Choice

Given the following class code: public class RecurseSample
{
Public static void main(String[] args)
{
System.out.println(recurse(3) ) ;
}
Public static int recurse(int n)
{
Int total = 0;
If (n == 0)
{
Return 0;
}
Else
{
Total = 3 + recurse(n - 1) ;
}
Return total;
}
}
What values will be printed when this code is executed?


A) 6
B) 9
C) 3, 6, and 9
D) 1, 3, 6, and 9

Correct Answer:

verifed

Verified

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

Related Questions