CS 2401 Quiz #4

Date: Tuesday, February 16, 2010.

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

1b. Can we use the Java class Vector to implement lists (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)
      {

		if (stars == 0)
			 return;

	 	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();
				
      }
}
Is the program above going to execute successfully or crash?

2b.