Q.1) What is Remote method invocation (RMI)? A. RMI allows us to invoke a method of java object that executes on another machine. B. RMI allows us to invoke a method of java object that executes on another Thread in multithreaded programming. C. RMI allows us to invoke a method of java object that executes parallely in same machine. D. None of the mentioned ANSWER : RMI allows us to invoke a method of java object that executes on another machine. Remote method invocationor RMI allows us to invoke a method of java object that executes on another machine.. Q.2) Java is designed for the distributed environment of the Internet, because it handles protocols A. UDP B. TCP/IP C. FTP D. TEL ANSWER : TCP/IP TCP is a connection-oriented transport protocol that sends data as an unstructured stream of bytes. By using sequence numbers and acknowledgment messages, TCP can provide a sending node with delivery information about packets transmitted to a destination node. Where data has been lost in transit from source to destination, TCP can retransmit the data until either a timeout condition is reached or until successful delivery has been achieved. T CP can also recognize duplicate messages and will discard them appropriately. If the sending computer is transmitting too fast for the receiving computer, TCP can employ flow control mechanisms to slow data transfer. TCP can also communicates delivery information to the upper-layer protocols and applications it supports. All these characteristics makes TCP an end-to-end reliable transport protocol. Q.3) RMI is about. A. Accessing remote objects and invoking methods from remote objects. B. java.lang.cloneable C. Passing objects between a server and a client D. Passing primitive data between a server and a client ANSWER : Accessing remote objects and invoking methods from remote objects. In the Java distributed object model, a remote object is one whose methods can be invoked from another Java Virtual Machine, potentially on a different host. An object of this type is described by one or more remote interfaces, which are Java interfaces that declare the methods of the remote object. Remote method invocation (RMI) is the action of invoking a method of a remote interface on a remote object. Most importantly, a method invocation on a remote object has the same syntax as a method invocation on a local object. Q.4) Java support RMI. What does this RMI stands for? A. Random Memory Interface Page 1
B. Remote Method Invocation C. Random Method Invocation D. Remote Memory Interface ANSWER : Remote Method Invocation Remote Method Invocation (Java RMI) enables the programmer to create distributed Java technology-based to Java technology-based applications, in which the methods of remote Java objects can be invoked from other Java virtual machines*, possibly on different hosts. RMI uses object serialization to marshal and unmarshal parameters and does not truncate types, supporting true object-oriented polymorphism. Q.5) A remote object must be an instance of. A. java.rmi.remote B. java.rmi.remoteobject C. java.io.serializable D. java.lang.cloneable ANSWER : java.rmi.remote All remote interfaces extend, either directly or indirectly, the interface java.rmi.remote. Q.6) is a subinterface of java.rmi.remote that defines the methods for the server object. A. Server stub B. Server implementation C. Server object interface D. RMI Registry ANSWER : Server object interface The java.rmi.remote interface serves to identify all remote objects, any object that is a remote object must directly or indirectly implement this interface. All remote interfaces must be declared public. Q.7) 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 RegisterWithRMIServer B. java java.security.policy=policy RegisterWithRMIServer C. java policy=policy RegisterWithRMIServer D. java RegisterWithRMIServer java java.security.policy=policy ANSWER : java java.security.policy=policy RegisterWithRMIServer The java.security.policy property, which is used to specify the security policy file that contains the permissions you intend to grant to various pieces of code. Q.8) The is used to handle the errors that may occur during the invocation of a Remote method. Remote Method Invocation uses Protocol A. Interface,TCP B. Exception,TCP C. Exception,UDP D. Interface,UDP Page 2
ANSWER : Exception,TCP There is diffrent type of Exception in RMI they are: 1.Exceptions During Remote Object Export 2.Exceptions During RMI Call 3.Exceptions or Errors During Return 4.Naming Exceptions These type of exception can occur during invocation of the remote method. Q.9) Which of these methods are member of Remote class? A. checkip() B. addlocation() C. AddServer() D. None of the mentioned ANSWER : None of the mentioned Remote class does not define any methods, its pupose is simply to indicate that an interface uses remote methods. Q.10) is a utility that registers remote objects and provides naming services for locating objects. A. Server stub B. Server object interface C. Server implementation D. RMI Registry ANSWER : RMI Registry The java.rmi.naming class allows remote objects to be retrieved and defined using the familiar Uniform Resource Locator (URL) syntax. The URL consists of protocol, host, port and name fields. The Registry service on the specified host and port is used to perform the specified operation. Q.11) To start an RMI registry, use from the command window. A. rmiregistry B. start rmiregistry C. rmiregistry 7000 D. start rmiregistry 7000 ANSWER : start rmiregistry,start rmiregistry 7000 To start the registry on the server, execute the rmiregistry command. This command produces no output and is typically run in the background. For example, on Windows 95 or Windows NT: start rmiregistry The registry by default runs on port 1099. To start the registry on a different port, specify the port number in the command. For example, to start the registry on port 7000 on Windows NT: start rmiregistry 7000 Q.12) What is the output of this program? import java.lang.reflect.*; class Additional_packages { public static void main(string args[]){ try { Page 3
Class c = Class.forName("java.awt.Dimension"); Constructor constructors[] = c.getconstructors(); for (int i = 0; i < constructors.length; i++) System.out.println(constructors[i]); catch (Exception e) { System.out.print("Exception"); A. Program prints all the constructors of java.awt.dimension package. B. Program prints all the possible constructors of class Class. C. Program prints Exception D. Runtime Error ANSWER : Program prints all the constructors of java.awt.dimension package. Output: $ javac Additional_packages.java $ java Additional_packages public java.awt.dimension(java.awt.dimension) public java.awt.dimension() public java.awt.dimension(int,int) Q.13) 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. Server Skeleton D. Server stub ANSWER : Server stub A stub for a remote object is the client-side proxy for the remote object. Such a stub implements all the interfaces that are supported by the remote object implementation. The client invokes a method that is offered by the server. The invocation is received by the stub. The stub arranges the request and data in a linear stream. This is known as marshalling and sends that information to the machine that the server resides on. Q.14) is a class that implements the remote object interface. A. Server object interface B. Server Skeleton C. Server stub D. Server implementation ANSWER : Server implementation The java.rmi.registry.registry remote interface provides methods for lookup, binding, rebinding, unbinding, and listing the contents of a registry. The java.rmi.naming class uses the registry remote interface to provide URL based naming. package java.rmi.registry; Q.15) Which of these Exceptions is thrown by remote method? A. RemoteException Page 4
B. RemoteException C. RemoteAccessException D. RemoteInputOutputException ANSWER : RemoteException All remote methods throw RemoteException.A RemoteException is the common superclass for a number of communication-related exceptions that may occur during the execution of a remote method call. Each method of a remote interface, an interface that extends java.rmi.remote, must list RemoteException in its throws clause. Q.16) At Client, remote object proxy is termed as A. Stub B. RemoteRef C. Skeleton D. Skeleton ANSWER : Stub In Client Server architecture remote object proxy is called Stub. b) RemoteRef : The Remote reference layer provides RemoteRef object that represents link to remote service implementation object. c) Skeleton is a helper class that is used how to communicate with stub across RMI link. Page 5