Name:

SE550 final exam: Spring 2000-2001

This is a closed-book, closed-note exam.

Answer all questions.

Time allowed: 2 hours

Total number of points: 100

Question 1 (15 points)

a) What is a remote pointer?

b) How is a remote pointer implemented?

c) What is a remote method invocation?

d) How is a remote method invocation implemented?

Question 1 continued

Question 2 (15 points)

For each of the following programs, say whether the message "hello world" is printed on the server or on the client. In each case, give a short (one or two sentence) explaination for your answer.

a)

class Client {
    public static void main (String[] args) throws Exception {
        String server = args[0];
        Printer p = (Printer)(Naming.lookup ("//" + server + "/printer"));
        p.println ("hello world");
    }
}
class Server {
    public static void main (String[] args) throws Exception {
        Naming.rebind ("printer", new PrinterImpl ());
    }
}
interface Printer extends Remote {
    public void println (String s) throws RemoteException;
}
class PrinterImpl extends UnicastRemoteObject implements Printer {
    public void println (String s) throws RemoteException {
        System.out.println (s);
    }
    PrinterImpl () throws RemoteException { super (); }
}

Question 2 continued

b)

class Client {
    public static void main (String[] args) throws Exception {
        String server = args[0];
        HelloWorld hw = (HelloWorld)(Naming.lookup ("//" + server + "/hw"));
        Printer p = new PrinterImpl ();
        hw.hw (p);
    }
}
class Server {
    public static void main (String[] args) throws Exception {
        Naming.rebind ("hw", new HelloWorldImpl ());
    }
}
interface HelloWorld extends Remote {
    public void hw (Printer p) throws RemoteException;
}
class HelloWorldImpl extends UnicastRemoteObject implements HelloWorld {
    public void hw (Printer p) throws RemoteException {
        p.println ("hello world");
    }
    HelloWorldImpl () throws RemoteException { super (); }
}
interface Printer extends Serializable {
    public void println (String s);
}
class PrinterImpl implements Printer {
    public void println (String s) {
        System.out.println (s);
    }
}

Question 2 continued

c)

class Client {
    public static void main (String[] args) throws Exception {
        String server = args[0];
        HelloWorld hw = (HelloWorld)(Naming.lookup ("//" + server + "/hw"));
        Printer p = new PrinterImpl ();
        hw.hw (p);
    }
}
class Server {
    public static void main (String[] args) throws Exception {
        Naming.rebind ("hw", new HelloWorldImpl ());
    }
}
interface HelloWorld extends Remote {
    public void hw (Printer p) throws RemoteException;
}
class HelloWorldImpl extends UnicastRemoteObject implements HelloWorld {
    public void hw (Printer p) throws RemoteException {
        p.println ("hello world");
    }
    HelloWorldImpl () throws RemoteException { super (); }
}
interface Printer extends Remote {
    public void println (String s) throws RemoteException;
}
class PrinterImpl extends UnicastRemoteObject implements Printer {
    public void println (String s) throws RemoteException {
        System.out.println (s);
    }
    PrinterImpl () throws RemoteException { super (); }
}

Question 3 (15 points)

a) What is distributed garbage collection?

b) What is object leasing?

c) Explain how Java uses object leasing in its implementation of distributed garbage collection.

Question 3 continued

Question 4 (15 points)

a) What is a class loader?

b) How does the default Java class loader load classes?

c) How does the RMI Java class loader differ from the default class loader?

d) Give an example of why the RMI Java class loader is different from the default class loader.

Question 4 continued

Question 5 (15 points)

One possible data representation for an RMI implementation is XML. For example, the following code fragment:

  Object foo = Naming.singleton.lookup ("//server/foo");
  foo.print ("hello");

would generate the following XML (ignoring method overloading and object handles) being sent from the client to the server:

  <Object class="Call">
    <String value="foo"/>
    <String value="print"/>
    <Array class="Object" length="1">
      <String value="hello"/>      
    </Array>
    <String value="result1">
  </Object>

and the following response from the server (assuming it returned null):

  <Object class="Return">
    <String value="result1">
    <Null/>
  </Object>

If the following code fragment causes "wilma" to be printed at the client, what XML is sent between the client and the server?

  Object foo = Naming.singleton.lookup ("//server/foo");
  System.out.println (foo.get ("fred", "flintstone"));

Question 5 continued

Question 6 (25 points)

a) What is a transaction? Give a short example of why transactions are necessary when a database is being accessed concurrently.

b) What are the ACID properties of a relational database? Give a short (one or two sentence) description of each property.

Question 6 continued

Worksheet

You can use this sheet as scrap paper.

Worksheet

You can use this sheet as scrap paper.

Worksheet

You can use this sheet as scrap paper.

Worksheet

You can use this sheet as scrap paper.