COM1204 Summer Quiz #1 review- Prof. Futrelle

Quiz #1 to be given on Thursday 3 July - Closed book/notes


There are three possible questions, of which only two will appear on the quiz. The questions will be quite similar to the ones below, with minor variations only.

First question: This involves writing Java code and discussing a bit just how it works.

The code for the above, which would appear in three separate .java files:


/**
 * Omnibus demo code for COM1204 Quiz #1, summer 2003.
 * R. P. Futrelle, Northeastern U. CCIS.
 */
public class TestYear {
public static void main(String[] args) {
	ThisYear tyear = new ThisYear();
	System.out.println(tyear.currentYear());
	}
} // class TestYear

public interface AnyYear {
	int currentYear();
} // interface AnyYear

public class ThisYear implements AnyYear{
	public int currentYear() {
		return 2003;
	}
} // class ThisYear


Second question: This involves writing Java code and discussing a bit just how it works.

The code for the above only requires a single file:


import java.util.*;
/**
 * Demo code for COM1204 Quiz #1, summer 2003.
 * R. P. Futrelle, Northeastern U. CCIS.
 */
public class Iter {
	public static void main(String[] args) {
		HashSet hash  = new HashSet();
		Vector vec = new Vector();
		
		hash.add("h1");
		hash.add("h2");
		vec.add("v1");
		vec.add("v2");
		
		Iterator hashIt = hash.iterator();
		while(hashIt.hasNext()) {
			System.out.println(hashIt.next());
		}
		
		Iterator vecIt = vec.iterator();
		while(vecIt.hasNext()) {
			System.out.println(vecIt.next());
		}
		} // main()
} // class Iter

Third question: Given an example such as one of the following, explain in what way they are examples of the Observer Pattern. This requires you to clearly explain what the basics of the Observer Pattern are, as well as interpreting the example in terms of the Observer Pattern. This is a technical question. You should try to give a technical and concise answer, not just vague remarks.


Go to COM1204 home page.

Return to Prof. Futrelle's home page