Introduction to Java Programming, Sixth Edition, Y. Daniel Liang

Chapter 36 Remote Method Invocation


Section 36.2 RMI Basics
1  RMI is about _______________.

A. passing primitive data between a server and a client
B. passing objects between a server and a client
C. accessing remote objects and invoking methods from remote objects.
D. java.lang.Cloneable

2  A remote object must be an instance of ______________.

A. java.rmi.RemoteObject
B. java.rmi.Remote
C. java.io.Serializable
D. java.lang.Cloneable

3  ____________ is a subinterface of java.rmi.Remote that defines the methods for the server object.

A. Server object interface
B. Server implementation
C. RMI Registry
D. Server stub
E. Server Skeleton

4  ____________is a class that implements the remote object interface.

A. Server object interface
B. Server implementation
C. RMI Registry
D. Server stub
E. Server Skeleton

5  ____________is a utility that registers remote objects and provides naming services for locating objects.

A. Server object interface
B. Server implementation
C. RMI Registry
D. Server stub
E. Server Skeleton

6  ___________ is an object that resides on the client host and serves as a surrogate for the remote server object.

A. Server object interface
B. Server implementation
C. RMI Registry
D. Server stub
E. Server Skeleton

7  ___________ is an object that resides on the server host, communicates with the stub and the actual server object.

A. Server object interface
B. Server implementation
C. RMI Registry
D. Server stub
E. Server Skeleton

8  Which of the following statements are true when passing arguments in a remoter method call.

A. Primitive data types, such as char, int, double, or boolean, are passed by value like a local call.
B. Local object types, such as java.lang.String, are also passed by value, but this is completely different from passing an object parameter in a local call. Any object can be used as a parameter in a remote call as long as it is serializable. The stub serializes the object parameter and sends it in a stream across the network. The skeleton deserializes the stream into an object.
C. Remote object types are passed differently from local objects. When a client invokes a remote method with a parameter of a remote object type, the stub of the remote object is passed. The server receives the stub and manipulates the parameter through it.
D. When a client invokes a remote method with parameters, passing the parameters is handled by the stub and the skeleton.

9  __________ provides the naming services for the server to register the object and for the client to locate the object.

A. Server object interface
B. Server implementation
C. RMI Registry
D. Server stub
E. Server Skeleton

10  Each remote object has a unique name identified by an URL with the protocol rmi as follows:

A. rmi://host:port/name
B. //host:port/name
C. http://host:port/name
D. http://host/name

Section 36.3 Developing RMI Applications
11  To register a remote object o with a name t at port 7000 on host panda.armstrong.edu, use

A. Naming.bind("rmi://panda.armstrong.edu:7000/t", o);
B. Naming.rebind("rmi://panda.armstrong.edu:7000/t", o);
C. Name.rebind("rmi://panda.armstrong.edu:7000/t", o);
D. Name.bind("rmi://panda.armstrong.edu:7000/t", o);

12  To locate a remote object with a name t at port 7000 on host panda.armstrong.edu, use

A. Remote remoteObj = Naming.lookup("rmi://panda.armstrong.edu:7000/t");
B. Remote remoteObj = Name.lookup("rmi://panda.armstrong.edu:7000/t");
C. Remote remoteObj = Name.lookup("//panda.armstrong.edu:7000/t");
D. Remote remoteObj = Name.lookup("http://panda.armstrong.edu:7000/t");

13  To start an RMI registry, use ____________ from the command window.

A. start rmiregistry
B. start rmiregistry 7000
C. rmiregistry
D. rmiregistry 7000

14  Assume that the file named policy contains the permission for registering a remote object with an RMI registry. To run the program (e.g., RegisterWithRMIServer) that registers a remote object with an RMI registry, use the command _________ from the command window.

A. java ?Djava.security.policy=policy RegisterWithRMIServer
B. java RegisterWithRMIServer java ?Djava.security.policy=policy
C. java RegisterWithRMIServer
D. java ?Dpolicy=policy RegisterWithRMIServer

Section 36.4 RMI vs. Socket-Level Programming
15  Which of the following statements are true?
A. RMI clients can directly invoke the server method, whereas socket-level programming is limited to passing values.
B. In socket-level programming, a client operation to send data requires a server operation to read it. The implementation of client and server at the socket-level is tightly synchronized.
C. RMI applications are scalable and easy to maintain. You can change the RMI server or move it to another machine without modifying the client program except for resetting the URL to locate the server.
D. RMI enables you to program at a higher level of abstraction. It hides the details of socket server, socket, connection, and sending or receiving data. It even implements a multithreading server under the hood, whereas with socket-level programming you have to explicitly implement threads for handling multiple clients.