Easy Multiple Choice QuestionsΒΆ

These problems are easier than most of those that you will usually see on the AP CS A exam.

11-6-1: Which line has the recursive call?

1
2
3
4
5
6
public static int factorial(int n)
{
   if (n == 0)
      return 1;
   else return n * factorial(n-1);
}





11-6-2: Which line has the recursive call?

1
2
3
4
5
6
7
8
public String starString(int n)
{
   if (n == 0) {
      return "*";
   } else {
      return starString(n - 1) + starString(n - 1);
   }
}






11-6-3: How many recursive calls does the following method contain?

1
2
3
4
5
6
7
8
public static int fibonacci(int n)
{
   if (n == 0)
      return 0;
   else if (n == 1)
      return 1;
   else return fibonacci(n-1) + fibonacci(n-2);
    }





11-6-4: How many recursive calls does the following method contain?

1
2
3
4
5
6
7
8
public static int multiplyEvens(int n)
{
   if (n == 1) {
      return 2;
   } else {
      return 2 * n * multiplyEvens(n - 1);
   }
}