Multiple Choice
Example Code Ch 12-3
Given the two recursive methods shown below, foo and bar.
Assume int[] a = {6, 2, 4, 6, 2, 1, 6, 2, 5}
public int foo(int[] a, int b, int j)
{
if (j < a.length)
if (a[j] != b) return foo (a, b, j+1) ;
else return foo (a, b, j+1) + 1;
else return 0;
}
public int bar(int[] a, int j)
{
if (j < a.length)
return a[j] + bar(a, j+1) ;
else return 0;
}
-Refer to Example Code 12-3: What is the result of calling foo(a, 3, 0) ?
A) 0
B) 1
C) 2
D) 3
E) 4
Correct Answer:

Verified
Correct Answer:
Verified
Q5: If one were to create a Towers
Q6: Define the magnitude of a number as
Q7: Describe how to solve the Towers of
Q8: Why is the following method one which
Q9: What is a fractal?<br>A) a portion of
Q11: The following method should return true if
Q12: Which of the following methods would properly
Q13: The difference between direct and indirect recursion
Q14: Example Code Ch 12-3<br>Given the two recursive
Q15: For the Towers of Hanoi problem, show