CS 2401 Quiz #6

Date: Monday, September 27, 2010.

1. Trace the following program step-by-step and describe what will be printed:

import java.util.*;

public class quiz6{

   static Vector‹Integer› trace = new Vector‹Integer›();

   public static void main(String[] args)
      {
       fibV(4);
       System.out.println(trace);
      }

   public static int fibV(int n)
      {
        int result;
        if (n == 1 || n == 2)
          {result = 1;}
        else
          {result = fibV(n - 1) + fibV(n - 2);}
        trace.insertElementAt(result,0);
        return result;
      }
}