Logo F2FInterview

RMI Interview Questions

Q   |   QA

The classes define the blueprint that consists of the methods and behavior of a particular structure. The classes are:

  • Remote class: is the class that consists of the instances that can be accessed remotely from the server and also consists of different properties that are required to be accessed by the client and server during request and response time.
  • Remote class object: wherever this object is defined the instances of the class can be accessed using other object. On other computers that are not in network it can be accessed through the use of object handles.
  • Serializable class: is the class that consists of instances that can be marshaled or turned in a linear sequence to represent the bits.
  • Serializable class objects: allows the request to be transmitted from one computer to
  • another. It allows the easy implementation of the serializable class. 

The conditions that has to be kept in mind while using serialization is that:

  • The class should be declared as public and it should implement the serializable version identifier that is given as serialVersionUID to read the serial versions that are being loaded or updated.
  • The class should not consists of any argument constructor and all the fields of the class should have a serializable field in it. This can be either primitive types or Serializable objects type.
  • The class doesn't itself declare any methods and an execption can be made in the fields that are made transient and these are ignored during serialization. 

To create a class serializable there is mechanism of serializing an object on the client code. There are four things that are required to make a class serializable and these are:

  • The first thing that has to be done is to implement the serializable interface that makes the process easy to convert the set of object references to the linear stream of bytes.
  • Check whether the instance level that is locally defined state is in serialized mode or not. Check that it has been implemented properly or not.
  • Check whether the superclass state in the serialized phase is properly managed and adjusted. If it is adjusted then with the help of few function the process can create a class serializable.
  • Then use the methods like equals( ) and hashCode( ) to override the already used functions. This will allow the addition of new code to be inserted. 

The implementation is the easy phase of the serializable class. At first this interface remains as an empty interface and it declares no methods or behavior at all. It has additing feature that is added to the implements serializable class to follow the class declarations. It is not required to make every object as serializable as there will also be some classes that might not be having any serialization required. For example, an instance of a file that actually represents a file gets created by using

File file = new File("c:\\career\\ride");

so to make this work there is no surity that is it require a serialized code to be written. The file class is having a different lifecyle than the serialized data and modification in it might remove the entire information. There are also platform dependencies that involves native code not used for serialization. 

RMI consists of a server and a client program. The application in RMI creates a number of remote objects that makes the references to the objects that are to be accessible. This way when a client makes a call to the method on remote objects then the reference is passed to one or more remote objects in server. It then invokes certain methods on them to provide few functionalities. RMI provides the mechanism to communicate and pass the information from one part to another using the distributed object applications. It requires to locate the remote objects so that the registry can be maintained for the remote objects with RMI's naming facility, rmiregistry, and the application that can pass the remote object references and return it as a normal operation.

In order to link this F2FInterview's page as Reference on your website or Blog, click on below text area and pres (CTRL-C) to copy the code in clipboard or right click then copy the following lines after that paste into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code: