Anda di halaman 1dari 4

Name:

CS (Advanced Distributed Java (Fall 04)) Instructor: Orlando Karam Quiz 1: RMI and CORBA, April 26, 2006 Duration: 30 minutes This examination paper consists of 4 pages and 11 questions. Please bring any discrepancy to the attention of the instructor. The number in brackets at the start of each question is the number of points the question is worth. For T/F questions, you may want to add a BRIEF explanation, so I can see your reasoning. Please show ALL your work. For instructors use:

Score 1 (4) 2 (3) 3 (4)


Subtotal

Score 4 5 6 7 (4) (15) (2) (15) 8 9 10 11 (12) (15) (15) (15)

Score

Subtotal

Subtotal

Total (104)
1. [4] (T/F) JAVA RMI lets you dene objects in any language, and then call them from a client written in a dierent language 2. [3]List three services CORBA provides that RMI doesnt

page 2 3. [4] (T/F) CORBA is much faster than RMI, but less robust 4. [4] (T/F) Each method in a remote interface must indicate it can throw an RmiException

5. [15]Dene a remote interface, called CalculatorInterface, that has three method, one called zeroAccum, that takes no arguments and returns no info, one called add, that takes one integer and returns no info and one called getAccum that returns an integer.

6. [2] BONUS: the above interface would correspond to a EJB

session

7. [15]Dene an implementation class for the above interface; call the class CalculatorImpl. The implementation should keep an accumulator, zero it when zeroAccum is called, add a number to it when add is called and return it when getAccum is called (acts kind of like a real-life calculator, the C key being zeroAccum)

page 3 8. [12]Dene a main method(dont worry about the class name) that creates a new instance of CalculatorImpl, and binds it to the name Calc (on the same host, default port)

9. [15]Dene a main method(dont worry about the class name) that nds a remote object implementing CalculatorInterface, bound to the name Calc (on the same host as the program and on the default port), and uses it to calculate and print the sum of 10, 20 and 30

page 4 10. [15]Write a static method (dont worry about the class) called writeObjectOnPort, that takes two parameters, an integer (the port) and an Object. The method creates a server socket, listening on the given port, and waits for a connection on that port. Once a connection is established, the method serializes the object to the client that established the connection and nishes.

11. [15]Write a static method (dont worry about the class) called readObjectFromServer, that takes two parameters, a string (the servers name), and an integer (the port) and returns an Object. The method connects to the specied server and port using a socket, and reads an object from the socket. The method then returns the object.

End of examination Total pages: 4 Total marks: 104

Anda mungkin juga menyukai