Purchase Solution

Java - What does the following program do? MysteryClass

Not what you're looking for?

Ask Custom Question

// Exercise 15.12 Solution: MysteryClass.java

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

Purchase this Solution

Purchase this Solution


Free BrainMass Quizzes
Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Javscript Basics

Quiz on basics of javascript programming language.