Exams Attended

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

RMI Interview Questions and Answers

Freshers / Beginner level questions & answers

Ques 1. Explain RMI Architecture?

RMI uses a layered architecture, each of the layers could be enhanced or replaced without affecting the rest of the system. The details of layers can be summarised as follows:

Application Layer: The client and server program
Stub & Skeleton Layer: Intercepts method calls made by the client/redirects these calls to a remote RMI service.
Remote Reference Layer: Understands how to interpret and manage references made from clients to the remote service objects.
Transport layer: Based on TCP/IP connections between machines in a network. It provides basic connectivity, as well as some firewall penetration strategies.

Is it helpful? Add Comment View Comments
 

Ques 2. What is the difference between RMI & Corba?

The most significant difference between RMI and CORBA is that CORBA was made specifically for interoperability across programming languages. That is CORBA fosters the notion that programs can be built to interact in multiple languages. The server could be written in C++, the business logic in Python, and the front-end written in COBOL in theory. RMI, on the other hand is a total Java solution, the interfaces, the implementations and the clients--all are written in Java.

RMI allows dynamic loading of classes at runtime. In a multi-language CORBA environment, dynamic class loading is not possible. The important advantage to dynamic class loading is that it allows arguments to be passed in remote invocations that are subtypes of the declared types. In CORBA, all types have to be known in advance. RMI (as well as RMI/IIOP) provides support for polymorphic parameter passing, whereas strict CORBA does not. CORBA does have support for multiple languages which is good for some applications, but RMI has the advantage of being dynamic, which is good for other applications.

Is it helpful? Add Comment View Comments
 

Ques 3. What are the services in RMI ?

An RMI "service" could well be any Java method that can be invoked remotely. The other service is the JRMP RMI naming service which is a lookup service.

Is it helpful? Add Comment View Comments
 

Ques 4. Does RMI-IIOP support code downloading for Java objects sent by value across an IIOP connection in the same way as RMI does across a JRMP connection?

Yes. The JDK 1.2 support the dynamic class loading.

Is it helpful? Add Comment View Comments
 

Ques 5. How many types of protocol implementations does RMI have?

RMI has at least three protocol implementations: Java Remote Method Protocol(JRMP), Internet Inter ORB Protocol(IIOP), and Jini Extensible Remote Invocation(JERI). These are alternatives, not part of the same thing, All three are indeed layer 6 protocols for those who are still speaking OSI reference model.

Is it helpful? Add Comment View Comments
 

Ques 6. Does RMI-IIOP support dynamic downloading of classes?

No, RMI-IIOP doesn't support dynamic downloading of the classes as it is done with CORBA in DII (Dynamic Interface Invocation).Actually RMI-IIOP combines the usability of Java Remote Method Invocation (RMI) with the interoperability of the Internet Inter-ORB Protocol (IIOP).So in order to attain this interoperability between RMI and CORBA,some of the features that are supported by RMI but not CORBA and vice versa are eliminated from the RMI-IIOP specification.

Is it helpful? Add Comment View Comments
 

Ques 7. Can RMI and Corba based applications interact ?

Yes they can. RMI is available with IIOP as the transport protocol instead of JRMP.

Is it helpful? Add Comment View Comments
 

Ques 8. What is Remote Procedure Calls, RPC?

A request from one program that is located in one computer can be used by another computer in a network environment without understanding the underlying network details. This is done by a protocol called Remote Procedure Calls. In this client / server environment (network environment), the request is from a client to the server that provides the service from a server.

RPC is also called as inter-process communication. RPC extends the normal procedure calls across the network which is necessary in distributed computing models and for harnessing the power of the multiple processors.

In distributed systems, a client calls a procedure stored on a server. This is called calling a remote procedure stored on a server. Though, the call is made as if the procedure was stored on the local machine.

The steps in which a RPC is made are:

* The client calls the procedure
* The client stub builds the message.
* The message is sent over the network.
* The Server OS gives the message to the server stub.
* The server stub unpacks the message.
* The stub makes a local call to the procedure.
* The server does the work and returns the result to the server stub.
* The stub packs the message and traps to the kernel.
* The remote kernel sends the message the client kernel.
* The client kernel gives the message to the client stub.
* The client stub unpacks the result and gives to the client.

Is it helpful? Add Comment View Comments
 

Ques 9. Explain the advantages and disadvantages of RPC.

Advantages of RPC:

* Server independent
* Process-oriented and thread oriented models supported by RPC
* The development of distributed systems is simple because it uses straightforward semantics and easier.
* Like the common communications between the portions of an application, the development of the procedures for the remote calls is quite general.
* The procedure calls preserves the business logics which is apt for the application.
* The code re-writing / re-developing effort is minimized.
* Enables the usage of the applications used in the distributed environment, not only in the local environment.
* RPC provides interoperability between CORBA ORB implementations.
* A lightweight RPC protocol permits efficient implementations.

Disadvantages of RPC:

* Context switching increases scheduling costs
* RPC is not a standard Ė it is an idea that can be implemented in many ways
* RPC does not solve the most of the distribution creation problems
* RPC is only interaction based. This does not offer any flexibility in terms of hardware architecture.
* RPC implementations are not yet mature.
* It requires the TCP/IP protocol. Other transport protocols are not supported yet.
* Not yet proven over wide-area networks.

Is it helpful? Add Comment View Comments
 

Ques 10. Explain the difference between RPC and RMI.

RMI:

* The remote objects are accessed by the references
* Implements object to object implementation among different java objects to implement distributed communication model.
- RMI passes the objects as parameters to remote methods.
- RMI invokes the remote methods from the objects

RPC:

* The process is through methods / functions
* Proxy server is involved in processing the procedure calls
* Calls a procedure remotely like invoking the methods
* The remoteness is not exactly transparent to the client

Is it helpful? Add Comment View Comments
 

Ques 11. Discuss in brief about Remote Method Invocation (RMI) and its working.

RMI is a java object equivalent process that invokes a method in a distributed environment.

RMI performs the communication among objects using object-to-object communication. RMI uses the objects distribution techniques and invokes methods of objects which are located in a remote site.

Working of RMI:

The code from machine A is being accessed for the object that is residing on machine B in a remote relocation. There are two intermediate objects called a 'stub' and a 'skeleton', which actually handles the communication. The following are the tasks that performed by these two objects:

Task that are to be handled by the stub object (on machine X):

* Building a information block which consists of
- an identifier of the remote object
- an operation number that describes the method to be called and
- the method parameters called marshaled parameters that are to be encoded into a suitable format for transporting over the network
* Sending the information to the server.

The tasks that are to be handled by the skeleton object (on machine Y) are:

* Unmarshalling the parameters
* Invoking the required method of the object which is lying on the server
* Capturing and returning the value if successful or an exception if unsuccessful , after the call on the server
* Marshalling the returned value
* Packaging the value that is in the marshaled form and sending to the stub on the client.

Subsequently the stub object unmarshals the return value or exception from the server as the case may be. This is the returned value of the remote method invocation. If an exception is thrown, the stub object will rethrow the exception to the caller.

Is it helpful? Add Comment View Comments
 

Ques 12. What is the difference between RMI and JMS?


RMI

* RMI is tightly-coupled mechanism.
* The destination object need to be available online at the time of sending messages from client to server.
* RMI has RPC-model

JMS

* JMS provides loosely coupled mechanism.
* The destination object need not be available online at the time of sending messages from client to server.
* JMS has messaging model.

Is it helpful? Add Comment View Comments
 

Ques 13. Explain how URL convention is used for accessing the registry.

The class rebind () method of java.rmi.Naming class is used to specify the port number . For example if the registry is running on a port number 3271 of an application named HelloRMIRegistry the following is the usage of the URL to reference the remote object:

Naming.rebind ("//host:1111/RMIRegistry", obj);

The URL stored on the web page needs to specify the non-default port number.
When the serverís remote objects created by the server can include the URL from which the stub class can dynamically be downloaded to the client. The following example depicts this:

java -Djava.rmi.server.codebase=http://host/username/codebase/examples.ExampleRMIURL

Is it helpful? Add Comment View Comments
 

Ques 14. Explain the various methods of registering and gaining access to the Remote Object.

The methods of remote objects are to be invoked by implementing the java.rmi.Remote interface.

Methods:

bind(): binds the specified name to the remote object. The name parameter of this method should be in an URL format.

unbind(): Destroys the binding for a specific name of a remote method in the registry

rebind(): Binds again the specified name to the remote object. The current binding will be replaced by rebinding.

list(): Returns the names of the names that were bound to the registry in an array form. These names are in the form of URL-formatted string.

lookup(): A stub, a reference will be returned for the remote object which is related with a specified name.

Is it helpful? Add Comment View Comments
 

Ques 15. Explain the steps to create RMI-based clients and server.


Creation of RMI-based Server:

* Create the Servant interface and the Servant component class
* To host these servant classes create the RMI Server
* Compile the class files and generate the Skeletons and IDL File
* Start up the Server

Creation of RMI-based Client:

* Create the Client class
* Copy the IIOP Stubs and compile the Client
* Make sure the Server is running and then startup the Client

Is it helpful? Add Comment View Comments
 

Ques 16. What is data transfer in RMI model.

Data in a file can be transferred by using the method getFileContents(filename) in the remote interface.

RMI supports to transfer data that is available in JDOM data objects.

Is it helpful? Add Comment View Comments
 

Ques 17. What is the role of Remote Interface in RMI?

Remote interfaces are defined by extending ,an interface called Remote provided in the java.rmi package. The methods must throw RemoteException. But application specific exceptions may also be thrown.

Is it helpful? Add Comment View Comments
 

Ques 18. Explain marshalling and demarshalling.

During communication between two machines through RPC or RMI, parameters are packed into a message and then sent over the network. This packing of parameters into a message is called marshalling.

On the other side these packed parameters are unpacked from the message which is called unmarshalling.

Is it helpful? Add Comment View Comments
 

Ques 19. What is a skeleton in RMI?

Server side stub is refered to as a skeleton.

Is it helpful? Add Comment View Comments
 

Ques 20. Explain the role of stub in RMI.

The role of the stubs is to marshal and unmarshal the messages that are sent and received on the client or the server side.

Is it helpful? Add Comment View Comments
 

Ques 21. What are the layers on which RMI implementation is built? Explain them.

The Stub/Skeleton Layer:

The stub/skeleton layer sits in between application layer and the rest of the RMI system and acts as an interface. This layer transmits the information to remote layer. This transmission is done through the marshalling of streams. These streams performs the object serialization.

A stub is a remote object at the client-side. This stub implements all the interfaces which remote object implementation supports.

A skeleton is a remote object at the server-side. This stub consists of methods that invokes dispatch calls to the remote implementation of objects.

The Remote Reference Layer:

The lower level transport interfaces is dealt by this layer. This layer carries a specific remote reference protocol independent of stub and skeletons.

Every remote object is implemented by choosing their individual remote reference subclasses.

The Transport Layer:

The transport layer sets up the connections to remote address spaces, manages them, monitors the connection liveliness, and listens the incoming calls.

The transport layer maintains the remote objectís table available in the address space, in a table. For incoming calls, the transport layer establishes a connection. It locates the target dispatcher of the remote calls and passes the connection to the dispatcher.

Is it helpful? Add Comment View Comments
 

Ques 22. Explain how RMI clients contact remote RMI servers.

* The client procedure calls the client stub in the normal way.
* The client stub builds a message and traps to the kernel.
* The kernel sends the message to the remote kernel.
* The remote kernel gives the message to the server stub
* The server stub unpacks the parameters and calls the server.
* The server does the work and returns the result to the stub.
* The server stub packs it in a message and traps to the kernel.
* The remote kernel sends the message to the clients kernel.
* The clients kernel gives the message to the client stub.
* The stub unpacks the result and returns to the client.

Is it helpful? Add Comment View Comments
 

Ques 23. What are the basic steps to write client-service application using RMI?

* Assigning the security manager and then obtaining the reference to the service
* Contacting the RMI registry to obtain the remote objectís reference and invoking its methods
* Requesting the name for the service
* Invoke the remote method.

Is it helpful? Add Comment View Comments
 

Ques 24. What is RMI?

RMI stands for Remote Method Invocation. Traditional approaches to executing code on other machines across a network have been confusing as well as tedious and error-prone to implement. The nicest way to think about this problem is that some object happens to live on another machine, and that you can send a message to the remote object and get a result as if the object lived on your local machine. This simplification is exactly what Java Remote Method Invocation (RMI) allows you to do. Above excerpt is from "Thinking in java". For more information refer to any book on Java.

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

Related interview subjects

Core Java interview questions and answers - Total 306 questions
Tomcat interview questions and answers - Total 16 questions
Apache Wicket interview questions and answers - Total 26 questions
Java Applet interview questions and answers - Total 29 questions
JAXB interview questions and answers - Total 18 questions
JMS interview questions and answers - Total 64 questions
Log4j interview questions and answers - Total 35 questions
Struts interview questions and answers - Total 84 questions
RMI interview questions and answers - Total 31 questions
Apache Camel interview questions and answers - Total 20 questions
JDBC interview questions and answers - Total 27 questions
Java 11 interview questions and answers - Total 24 questions
JPA interview questions and answers - Total 41 questions
EJB interview questions and answers - Total 80 questions
GWT interview questions and answers - Total 27 questions
Kotlin interview questions and answers - Total 30 questions
Glassfish interview questions and answers - Total 8 questions
Google Gson interview questions and answers - Total 8 questions
JSP interview questions and answers - Total 49 questions
J2EE interview questions and answers - Total 25 questions
Apache Tapestry interview questions and answers - Total 9 questions
Java Swing interview questions and answers - Total 27 questions
Java Mail interview questions and answers - Total 27 questions
Hibernate interview questions and answers - Total 52 questions
JSF interview questions and answers - Total 24 questions
Java 8 interview questions and answers - Total 30 questions
Java 15 interview questions and answers - Total 16 questions
JBoss interview questions and answers - Total 14 questions
Web Services interview questions and answers - Total 10 questions
RichFaces interview questions and answers - Total 26 questions
Servlets interview questions and answers - Total 34 questions
Java Beans interview questions and answers - Total 57 questions
Spring Boot interview questions and answers - Total 50 questions
JUnit interview questions and answers - Total 24 questions
Spring Framework interview questions and answers - Total 53 questions
Java Design Patterns interview questions and answers - Total 15 questions
©2023 WithoutBook