Solved

Consider the Following Definition of a Recursive Method

Question 46

Multiple Choice

Consider the following definition of a recursive method. public static int mystery(int[] list, int first, int last) {if (first == last) return list[first]; else return list[first] + mystery(list, first + 1, last) ;} Given the declaration int[] alpha = {1, 4, 5, 8, 9}; What is the output of the following statement? System.out.println(mystery(alpha, 0, 4) ) ;


A) 1
B) 18
C) 27
D) 32

Correct Answer:

verifed

Verified

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

Related Questions