What does the following program do? public class MysteryClass { public static int mystery(int[] array2, int size)

Question:

What does the following program do?
    public class MysteryClass {
    public static int mystery(int[] array2, int size) {
    if (size == 1) {
    return array2[0];
    }
    else {
    return array2[size - 1] + mystery(array2, size - 1);
    }
    }

    public static void main(String[] args) {
    int[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

    int result = mystery(array, array.length);
    System.out.printf("Result is: %d%n", result);
    }
    }

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Java How To Program Early Objects

ISBN: 9780134743356

11th Edition

Authors: Paul Deitel, Harvey Deitel

Question Posted: