Question: Predict the Output: class R { static int dosomething ( int a [ ] , int i , int n ) { if ( n

Predict the Output:
class R
{
static int dosomething(int a[],int i, int n)
{
if (n0) return 0 ;
else if(a[i]2==0 return a[i]+ dosomething(a, i+1, n-1);
else return a[i]- dosomething(a, i+1, n-1);
}
public static void main(String args[])
{
int a[]={5,12,8,10,3,16,2,1};
System.out.print (i:dosomething(a,i:0,n:8)); }
}
A.-9
B.5
C.19
D.15
 Predict the Output: class R { static int dosomething(int a[],int i,

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!