Public class


public class MysteryClass
{
public int mystery( int array2[], int size )
{
if ( size == 1 )
return array2[ 0 ];
else
return array2[ size - 1 ] + mystery( array2, size - 1 );
} // end method mystery
} // end class MysteryClass

// Exercise 15.12 Solution

public class MysteryTest
{
public static void main( String arg[] )
{
MysteryClass mysteryObject = new MysteryClass();
int array[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int result = mysteryObject.mystery( array, array.length );
System.out.printf( "Result is: %dn", result );
} // end method main
} // end class MysteryTest

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Public class
Reference No:- TGS01250853

Now Priced at $20 (50% Discount)

Recommended (91%)

Rated (4.3/5)