-
E-MailHelpPoliciesSolutionsStudy-AidsSyllabusTools
Sample Questions for the Final Exam


  1. Answer the "Sample Questions for the Mid-Term Exam".

  2. Do the following architectural designs qualify as "Pipe and Filter" (as I defined that term in lecture)? Explain your answer!

  3. What is an abstract class? How should they be used?

  4. Name the following class member visibility categories.

    Visible within the declaring class and to selected other classes or operations.



    Visible everywhere that the class is visible.



    Visible only within the declaring class.



    Visible within the declaring class and in all its sub-classes.



  5. In Java:
    1. How would you instantiate an object of the class SoundStage?

    2. In a constructor of a derived class, how do you call the parent's constructor?

    3. Explain the difference between an interface and a class.

    4. What are the differences between static methods and other methods.

  6. I was developing a class model for an application I'm working on recently and was interrupted by a visiting student from Virginia Tech. I had gotten to the point where I had identified two classes and their attributes as follows:

    He suggested that I start using the following generalization:

    Do you agree with him? Why or why not?

  7. I've developed an email system called JMUmble. In this system, arriving messages are handled by a PostOffice object. Depending on how the system is configured at runtime, one or more objects might need to know when a message arrives. I have currently implemented several such classes: ScreenFlasher (which makes the entire screen flash -- you always know when a message has arrived), PopularityTimer (which starts a clock that show the amount of time since the most recent message arrived), and Mumbler (which uses speech generation to read the name of the person that sent the message -- this is where the system got its name). Use the observer pattern to develop a class model of this system (in UML). You do not need to include the attributes of each class, only the operations/methods. Include comments that describe each operation/method.

  8. Modify the following implementation of the GateListenerDatabase class so that it is impossible to construct more than one instance of it. Use the singleton pattern.
    import java.util.*;
    
    /**
     * A database of GateListenerRecord objects
     *
     */
    public class GateListenerDatabase
    {
        private Hashtable              db;
    
    
    
        /**
         * Construct a new GateListenerDatabase
         */
        public GateListenerDatabase()
        {
    	db = new Hashtable();
        }
    
    
    
        /**
         * Add a GateListenerRecord to the database
         *
         * @param glr  The record to add
         * @return     true if successful and false otherwise
         */ 
        public boolean add(GateListenerRecord glr)
        {
    	boolean            added;
    	GateListenerRecord old;
    	String             key;
    
    
    	added = false;
    
    	key = glr.getHost()+":"+glr.getPort();
    	old = (GateListenerRecord)(db.get(key));
    
    	if (old != null) {
    
    	    added = false;
    
    	} else {
    
    	    added = true;
    	    db.put(key, glr);
    	}
    
    	return added;
        }
    
    
    
    
        /**
         * Drop a GateListenerRecord from the database
         *
         * @param glr  The record to drop
         * @return     true if successful and false otherwise
         */
        public boolean drop(GateListenerRecord glr)
        {
    	boolean   dropped;
    	Object    oldkey;
    	String    key;
    
    
    	key = glr.getHost()+":"+glr.getPort();
    	oldkey = db.remove(key);
    
    	dropped = true;
    	if (oldkey == null) dropped = false;
    
    	return dropped;
        }
    
    
    
        /**
         * Returns an Enumeration containing all of the GateListenerRecord 
         * Objects in the database
         *
         * @return  The Enumeration of records
         */
        public Enumeration getAll()
        {
    	return db.elements();
        }
    
    }
        

  9. Consider the following design model:

    1. What role in the composite pattern is played by:

      Shape



    2. What role in the composite pattern is played by:

      Line



    3. What role in the composite pattern is played by:

      Rectangle



    4. What role in the composite pattern is played by:

      Text



    5. What role in the composite pattern is played by:

      Drawing



    6. What method in this model plays the role (in the composite pattern) of:

      operation()



Copyright ©2004