JMU JMU - Department of Computer Science
Help Tools
Sample Questions for Exam 3


  1. Indicate whether each of the following dates is "little-endian" (i.e., least signficiant component first), "big-endian" (i.e., most signficiant component first), or neither:
    1. July 4, 1776
    2. 4 July 1776
    3. 1776 July 4
    4. July 1776 4
  2. A "proxy server" acts as an intermediary between clients (perhaps many at the same time) and a server. That is, it takes any requests it receives from clients and forward them to the real server and, similarly, forwards any responses it receives from the server to the real clients.

    With this in mind, complete the following HTTPProxyServer class:

      import java.io.*;
      import java.net.*;
    
    
      public HTTPProxyServer implements Runnable
      {
          private  ServerSocket        ss;
    
    
          public HTTPProxyServer(String actualHost, int actualPort, 
                                 int intermediaryPort)
          {
    
    
    
    
          }
    
    
    
    
          public void run()
          {
    
    
    
    
          }      
      }
      

    You may create additional classes if needed.

  3. Carefully explain:
    1. Whether XSLT documents should be thought of as "data" or "code".
    2. The concept of a namespace.
    3. The differences between and similarities of XML DTDs and XML Schemas.
    4. The differences between and similarities of XML and JSON.
    5. The differences between and similarities of JAXP and JSON-P.
  4. In XSLT:
    1. How would you define a "rule" for an author element?
    2. How would you denote the finalgrade element inside of a student element?
    3. How would you denote the width attribute inside of a trailer element?
  5. Build a hierarchical model of an address book that contains addresses, phone numbers (of various kinds), and email addresses. Provide three sample entries in both XML and in JSON.
  6. Write an XML schema and a JSON schema for the address book that you created in the previous question.
  7. Consider the following XML document:
      <play>
        <title>All's Well That Ends Well</title>
        <personae>
          <persona>KING OF FRANCE</persona>
          <persona>DUKE OF FLORENCE</persona>
          <persona>BERTRAM, Count of Rousillon.</persona>
          <persona>LAFEU, an old lord.</persona>
        </personae>
      </play>
      

    Write an XSLT program that will convert an XML document containing a group of plays into a table with the title in the first column and the personae in subsequent columns (delimited by the '|' character). (Note: All plays will not have the same number of personae.)

  8. Write an application (that includes a class that extends DefaultHandler and a driver) that can use a SAXParser to list all of the persona in a play (of the kind in the previous question).
  9. Create a JSON document that is equivalent to the XML document that contains the above play.
  10. Write an application that uses JSON-P to list all of the persona in a play (of the kind in the previous question).
  11. Carefully explain:
    1. Three uses of serialization.
    2. One way in which references complicate serialization.
    3. The use of proxies in remote method invocation.
  12. In the lecture on the Strategy Pattern we developed a simple Posterizer class. It had a setMetric() method that was passed a Metric and a toBlackAndWhite() method that was passed a BufferedImage object. That version was designed to run on a single machine. For this question you must write a distributed version of this system using object transport.
    1. Create a serializable PosterizerParameters class that contains a Metric and a BufferedImage.
    2. Write a PosterizerServer that can: receive a PosterizerParameters object, construct a Posterizer object, posterize the image appropriately, and respond with the transformed BufferedImage. It must use TCP and handle one connection at a time (to avoid conflicts).
    3. Write a PosterizerClient that: serializes a PosterizerParameters object, transmits the serialized version to a PosterizerServer, and receives the result.
  13. Complete the following class:
      import java.lang.reflect.*;
    
      public class ObjectFactory
      {
        /**
         * Uses reflection to create an Object of a given class
         *
         * @param  className   The name of the class (e.g., String)
         * @return             An instance of the given class
         */
        public Object createObject(String className)
        {
    
    
    
    
    
    
    
    
    
    
    
    
    
        }
      }
      
  14. Design a server (using the ObjectFactory class above) that can be used by remote clients to construct objects of different kinds.
  15. Returning to the server in the previous question:
    1. When might such a server be useful (i.e., what kinds of applications could make use of such a server)?
    2. Does such a server need to be able to transport classes? Why or why not?
  16. In large enterprises it is common for many clients to be connected to the same external (i.e., outside of the enterprise) server. For example, many people may be connected to the same weather server.

    One way to improve the efficiency of such situations is to have the clients connect to an "internal" proxy and have the proxy connect to the "external" server. With such a system, the information only needs to be transmitted from the "external" server once. Then, the "internal" proxy can re-transmit the information to each client.

    Design such a system using servlets (in UML).

Copyright 2020