CS 2401 Quiz #4

Date: Monday, February 15, 2010.

1a. Can we use the Java class Vector to implement lists (yes or no)?

1b. Does Java have a mechanism that allows programmers to create their own data types (yes or no)?

2a. Consider the following program:

import java.util.*;

public class pattern {

   public static void main(String[] args)
	 {
		printPattern(3);
	 }
			
   public static void printPattern(int stars)
      {
	 	int i;

		for (i = 0; i < 2 * stars; i++)
			System.out.print("*");	
		System.out.println();

		printPattern(stars - 1);		
		
		for (i = 0; i < 2 * stars; i++)
			System.out.print("*");	
		System.out.println();

		if (stars == 0)
			 return;
				
      }
}
Is the program above going to execute successfully or crash?

2b.