Remote Method Invocation Interview Questions & Answers

4 avg. rating (80% score) - 1 votes

Remote Method Invocation Interview Questions & Answers

Searching for a Remote Method Invocation job? If you are an expert in Remote Method Invocation then this is for you. Do not worry, we’ve a right answer for your job interview preparation. If you are preparing for Remote Method Invocation job interview, we will help you in clearing the interview through Wisdomjobs interview questions and answers page. Remote Method Invocation is way of programming where objects on different computers are interacted in a network. It is similar to Remote Procedure Call. RMI is implemented in three layers, a stub program, a remote reference layer and a transport connection layer. Good knowledge on Programming is required for this job. Below are the Remote Method Invocation interview questions and answers which makes you comfortable to face the interviews:

Remote Method Invocation Interview Questions

Remote Method Invocation Interview Questions
    1. Question 1. What Is The Method That Is Used By The Rmi Client To Connect To Remote Rmi Servers?

      Answer :

      RMI is known as Remote method invocation and to for the RMI client to connect to remote RMI server first thing is to get hold on a reference of the server.

      The Naming.lookup method is used to as a mechanism that is used to provide the way to obtain the references to remote servers. The remote servers can be obtained by using the remote calls that return remote references. This also uses a stub to make a remote method call used in rmiregistry that sends back to remote reference.

      Then the references consists of a server hostname and port number, which allow clients to locate a virtual machine. This virtual machine is used to allow the remote object to be found and connected. After the remote reference are provided to RMI client, then it will be easy to use hostname and port that is provided to open the socket connection to a remote server.

    2. Question 2. What Is The Function Of Java.net.unknownhostexception?

      Answer :

      The java.net.UnknownHostException method is used as remote calling and for callback routine fail. RMI uses default settings to resolve the server hostname like WINS names, DHCP names, etc. This happens due to which RMI client invokes the remote method using the reference that consists of unresolved server hostname and the client will produce UnknownHostException. RMI servers provide fully qualified hostname or IP address to resolve all RMI clients error reports. RMI provides an operation to remotely callback a program that serves RMI object and provide resolvable hostname to pass it to the RMI clients. UnkownHostException is thrown when an applet is failed to provide a useable server hostname. The property java.rmi.server.hostname can be set to get from the server the correct IP address or hostname.

    3. Question 3. What Are The Reasons Of Getting Unknownhostexception Error Even If All The Setting Are Properly Configured?

      Answer :

      The UnkownHostException error can come for many reasons. To find out first there is a need to know the network's name service that is having a fully-qualified hostname recognized by RMI host. The possible problems that might come are:

      There is a possibility of having misconfigured DHCP servers that allows fully-qualified domain name of RMI server machines. RMI client in this case try to access the outside server's DHCP domain that will make it unavailable for the server.

      There is a possibility of having the error due to WINS server. It is possible that only registered users might not be reachable by hosts.

      There is a possibility of having a firewall that is blocking the RMI client and server side requests. If the server resides inside the firewall and the client outside then the client won't be able to make any remote calls to the server that is inside due to the firewall.

    4. Question 4. What Is The Use Of Http-tunneling In Rmi?

      Answer :

      HTTP-Tunneling is a method that requires no setup and works within the firewall environment. It allows the handling of HTTP through proxy server and doesn't allow regular outbound TCP connections. If the RMI fails to make any connection specially SOCKS then connection is made through an intended server that allow the HTTP proxy server to be configured. This will allow the request to be passed through the proxy server one by one.

      The forms of HTTP-tunneling are http-to-port: where the RMI attempt to use HTTP POST request using a URL that will be directed at the hostname and port number of the server that is given. If the proxy accepts the URL it will forward a POST request to listen to RMI server that will remove the request of the name. There is an http-to-cgi tunneling that will consists of the requests and allow the proxy request to be binded to their defined port numbers.

    5. Question 5. How Does Distributed Garbage Collection Manages The Disconnections Detected On The Client Side?

      Answer :

      RMI uses a runtime client that a virtual machine detects of the remote object that is not referenced locally. It notify the server in came of any disconnections and this way the server can be updated by the object's set. The garbage collector that is distributed associate an address with each client remote object reference.

      It also renew the remote objects while the client still consists of the references. This mechanism will allow the abnormal termination of the clients so that server can hold the remote objects that are not referenced using the message that are stopped running. The function System.exit() can be invoked for abnormal termination, as it doesn't allow the RMI runtime to send a proper messages to the server. This function will terminate the client virtual machine and will keep the remote references that will be cleaned up before exiting.

      The other functions that are used for this are:

      • System.gc();
      • System.runFinalization();

    6. Question 6. What Is The Relationship Between The Rmi And Corba?

      Answer :

      RMI is a distributed object system that provides and enable to easily develop the distributed Java applications. It is easier to develop applications using the RMI method then using the sockets. It doesn't require any protocol for design that makes it less prone to error for the tasks performed by it. RMI is allows the local method to be called from a local class file and the remote methods are interpreted and are sent back to the callers.

      The CORBA also having the same features that are seen in RMI. It is a platform and language independent architecture that can be run on any platform. It can be located from anywhere on the network and can be used in any language that has a mapping with IDL (Interface definition language). The objects of this are specified with interfaces that are specified in the interface language.

    7. Question 7. What Are The Different Terms That Are Used In Rmi?

      Answer :

      There are different terms that are used in RMI that helps in calling the remote servers and allow an easy to use terminology to be created:

      • Remote object: It is an object that is provided on another computer to request the object by sending a message to the object to the remote servers.
      • Server object: It is an object of the server side that receive the request and respond to the request of the client in success or failure.
      • rmiregistry: It is the registry that keeps the look ups of all the objects in a list by given name. This registry consists the list of all the components that are given in it.
      • Rmic: It is a compiler for RMI object.

      After creating the object the compiler compiles the object and it will generate the actual code that is to be transferred to the client side.

    8. Question 8. What Are The Different Types Of Classes That Are Used In Rmi?

      Answer :

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

      The classes are:

      Remote class: It 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: It is the class that consists of instances that can be marshaled or turned in a linear sequence to represent the bits.

      Serializable class objects: It allows the request to be transmitted from one computer to another. It allows the easy implementation of the serializable class.

    9. Question 9. What Are The Different Conditions That Has To Be Kept In Mind When Using Serialization Concept?

      Answer :

      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.

    10. Question 10. What Is The Process Of Making A Class Serializable?

      Answer :

      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

    11. Question 11. What Is The Procedure Of Implementation Of The Serializable Interface?

      Answer :

      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.

    12. Question 12. What Is The Main Purpose Of Distributed Object Applications In Rmi?

      Answer :

      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.

    13. Question 13. How Does The Communication With Remote Objects Occur In Rmi?

      Answer :

      RMI handles the remote objects that are being provided between the server and client computers. The difference between the objects are handled using RMI as well. RMI uses the standard method invocation to communicate between one object or another object. It loads the class byte-codes for objects that are passed using the defined parameters and return the values to the server in case of failure or success of it. RMI also allows the transmission to be done when passing the data as well.

      The string that is used by the RMI registry is “rmi://hostname:port/remoteObjectName", this allows the RMI registry to know the correct object and create a connection between different objects through this. If the hostname is not defined then local host can be used instead of it and this will also establish the connection

    14. Question 14. What Are The Steps That Are Involved In Rmi Distributed Applications?

      Answer :

      RMI distributed applications uses certain steps that defines the path mentioned in the registry. It has the following steps:

      • It uses the registry that stores the location and important information about the remote object.
      • It uses the registry to obtain the references to a remote object that keeps all the information and allow further communication to be done.
      • The server calls the registry to associate the name with the remote object and then the client sends the request for the object.
      • The client searches the remote object by its name in the registry on the server and invokes a method on it.
      • RMI uses a web server to load the bytecodes of classes to use the communication for the client and server.
      • RMI can load the class using the Internet protocols like HTTP, FTP, file, and etc.

    15. Question 15. What Is The Use Of Java.rmi.remote Interface In Rmi?

      Answer :

      RMI uses a remote interface declaring the methods that are invoked from a virtual machine and further forwarded to the server to take any request coming from the client.

      Java.rmi.Remote provides an interface declaring a set of methods that invokes the virtual machine to fulfill the requirements.

      This allows the extension of the interface directly or indirectly.

      Each method declaration in remote interface must have the exception policy such as java.rmi.RemoteException or java.io.IOException or java.lang.Exception clause that can be made application specific and it reduces the effort to extend java.rmi.RemoteException.

      Remote method declares the object as a parameter or the return value and that has to be declared using the remote interface

    16. Question 16. Write A Program To Show The Remote Interface Using Rmi?

      Answer :

      Remote interface allows the extension of the interface of java.rmi.Remtoe.

      This interface extends it non-remotely using the condition that this extend the interface when all the methods used are also extended in the interface that satisfy all the requirements of a remote method declaration.

      The example code shows the remote interface that is used in general:

      public interface Bank extends java.rmi.Remote
      {
      public void deposit(float amount)
      throws java.rmi.RemoteException;
      public void withdraw(float amount)
      throws OverdrawnException, java.rmi.RemoteException;
      public float getBalance()
      throws java.rmi.RemoteException;
      }

      The class of this extends the java.rmi.Remote to inherit the behavior and properties used by this specified class.This also uses several other class objects for example:

      java.rmi.server.RemoteObject and java.rmi.server.RemoteServer.

    17. Question 17. Write A Program To Show The Distributed Object Model Using Rmi?

      Answer :

      To implement the distributed object model a class is required that implements a remote interface extending the functionality of java.rmi.Remote and other classes such as java.rmi.server.UnicastRemoteObject.

      The implementation then take the responsibility for exporting the object having the correct use of remote semantics provided using hashCode, equals, and toString methods that are inherited from the java.lang.Object class.

      The code is given below as:

      public void withdraw(float amount) throws OverdrawnException,
      RemoteException
      // write your own statements
      }
      public float getBalance() throws RemoteException
      {
      // write your own statements
      }

    18. Question 18. Why Are Stubs Used In Rmi?

      Answer :

      RMI uses a mechanism that is standard for all the system and it is used to communicate with all the remote objects that are available. So, stubs are used to store the objects in the database so that it can be used later on. A stub is used for remote objects that act as a client’s local proxy for the remote object. This way the caller of the object calls the method on the local stub that becomes responsible to carry out the method call on the remote objects.

      RMI uses stub for a remote object that implements the same set of remote interfaces that is implemented by remote object. The stub is used to initiate the connection between the object and the java virtual machine. It marshalls that includes write and transmit the parameters to the remote java virtual machine that includes the method invocation. It allows the unmarshalling of the object to return the true value or the exception to be returned to the caller. The stub is used to hide the serialization of the parameter at network-level for the communication to be proceeded without any disturbance.

    19. Question 19. Why Is The Function Or Role Of Skeleton In Rmi?

      Answer :

      Every object that can be remotely accessed have a corresponding skeleton that functions like the original object. It is responsible for dispatching the call that is made to the actual remote object for the implementation and allow it to be implemented using the services provided by RMI. It allows the incoming method invocation to unmarshals i.e. only read the parameters used for the remote method. It invokes the method that is used by the actual remote object and after implementation marshals the result to the caller who is the original caller for the object.

    20. Question 20. How Does Dynamic Class Loading Happens In Rmi?

      Answer :

      RMI uses different parameters with values and exceptions and they all has to be passed for RMI calls. It creates the object that is serializable.

      RMI uses the serialization mechanisms to transfer the data from one machine to another using the virtualization concept. This is done so that the caller can receive the files on time. When the parameters return the values of the method invocation and unmarshals it then the live objects gets received by the java virtual machines.

      The unmarshalling process tries to resolve the name issue of the classes by loading the context class using the current thread. RMI provides the dynamic loading of the class definition to be done using actual types of objects that are passed as parameters and return values for RMI.

      This allows the dynamic loading of the remote stub classes that are related to a particular remote object that takes part in implementation of the classes.

      RMI also uses special subclasses of java.io.ObjectOutputStream and java.io.ObjectInputStream for marshilling and unmarshalling.

    21. Question 21. What Is The Difference Between Url Instance And Urlconnection Instance?

      Answer :

      A URL instance represents the location of a resource, and a URLConnection instance represents a link for accessing or communicating with the resource at the location.

    22. Question 22. How Do I Make A Connection To Url?

      Answer :

      You obtain a URL instance and then invoke openConnection on it. URLConnection is an abstract class, which means you can’t directly create instances of it using a constructor. We have to invoke openConnection method on a URL instance, to get the right kind of connection for your URL. Eg. URL url;

      URLConnection connection;
      try {
      url = new URL(”…”);
      connection = url.openConnection();
      } catch (MalFormedURLException e) { }

    23. Question 23. What Is A Socket In Java Networking And Rmi?

      Answer :

      A socket is one end-point of a two-way communication link between two programs running on the network. A socket is bound to a port number so that the TCP layer can identify the application that data is destined to be sent. Socket classes are used to represent the connection between a client program and a server program. The java.net package provides two classes–Socket and ServerSocket–which implement the client side of the connection and the server side of the connection, respectively.

    24. Question 24. What Information Is Needed To Create A Tcp Socket?

      Answer :

      The Local System's IP Address and Port Number. And the Remote System’s IPAddress and Port Number.

    25. Question 25. What Are The Two Important Tcp Socket Classes?

      Answer :

      Socket and ServerSocket. ServerSocket is used for normal two-way socket communication. Socket class allows us to read and write through the sockets. getInputStream() and getOutputStream() are the two methods available in Socket class.

    26. Question 26. When Malformedurlexception And Unknownhostexception Throws?

      Answer :

      When the specified URL is not connected then the URL throw MalformedURLException and If InetAddress? methods getByName and getLocalHost are unable to resolve the host name they throw an UnknownHostException.

    27. Question 27. What Does Rmi Stand For?

      Answer :

      It stands for Remote Method Invocation.

    28. Question 28. What Is Rmi?

      Answer :

      RMI is a set of APIs that allows to build distributed applications. RMI uses interfaces to define remote objects to turn local method invocations into remote method invocations.

    29. Question 29. What Is The Difference Between The File And Randomaccessfile Classes?

      Answer :

      The File class encapsulates the files and directories of the local file system. The RandomAccessFile class provides the methods needed to directly access data contained in any part of a file.

    30. Question 30. What Interface Must An Object Implement Before It Can Be Written To A Stream As An Object?

      Answer :

      An object must implement the Serializable or Externalizable interface before it can be written to a stream as an object.

    31. Question 31. Explain Rmi Architecture?

      Answer :

      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.

    32. Question 32. What Is The Difference Between Rmi & Corba?

      Answer :

      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.

    33. Question 33. What Are The Services In Rmi ?

      Answer :

      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.

    34. Question 34. How Many Types Of Protocol Implementations Does Rmi Have?

      Answer :

      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.

    35. Question 35. Does Rmi-iiop Support Dynamic Downloading Of Classes?

      Answer :

      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.

    36. Question 36. Can Rmi And Corba Based Applications Interact ?

      Answer :

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

    37. Question 37. What Is Remote Procedure Calls, Rpc?

      Answer :

      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.

    38. Question 38. Explain The Advantages And Disadvantages Of Rpc?

      Answer :

      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.

    39. Question 39. Explain The Difference Between Rpc And Rmi?

      Answer :

      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.

    40. Question 40. What Is Unicast And Multicast Object?

      Answer :

      The difference between unicast and multicast is that in unicast approach the sender sends the data stream to a single receiver at a time. Thus there is one to one communication.

      In a multicast the sender and the interested receivers communicate. This is one to many communication. This communication can take place between data terminals spread across various LANs too.

    41. Question 41. What Are The Basic Steps To Write Client-service Application Using Rmi?

      Answer :

      • 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.

    42. Question 42. Explain How Rmi Clients Contact Remote Rmi Servers?

      Answer :

      • 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.

    43. Question 43. What Are The Layers On Which Rmi Implementation Is Built? Explain Them.?

      Answer :

      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.

    44. Question 44. Explain The Role Of Stub In Rmi.?

      Answer :

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

    45. Question 45. What Is A Skeleton In Rmi?

      Answer :

      Server side stub is referred to as a skeleton.

    46. Question 46. Explain Marshalling And Demarshalling?

      Answer :

      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.

    47. Question 47. What Is The Role Of Remote Interface In Rmi?

      Answer :

      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.

    48. Question 48. What Is Rmi Callback Mechanism?

      Answer :

      When one service passes an object which is the proxy for another service, the RMI callback mechanism occurs. The methods will be invoked by the recipient in the object it received and be calling back to the calling point. The stub contains the information that is needed to call back to server at the time of the need.

    49. Question 49. What Is Object Serialization In Rmi?

      Answer :

      To marshal and unmarshall the parameters involves the object serialization and does not truncate types.

      The methods of local object and their bytecodes are not passed directly in the ObjectOutputStream. At times the name of the class of the objects may be needed that is to be loaded by the receiver if at all the class is not available locally. Just like the names of the classes, the class files themselves will not be serialized. All classes must load during the process of deserialization using the normal mechanisms of class loading.

    50. Question 50. What Is Data Transfer In Rmi Model?

      Answer :

      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.

    51. Question 51. What Are Remote Callbacks?

      Answer :

      In client-server technology / architecture, a server responds to a remote client. A call back is a method invocation from one application (Application A) from another application (Application B), as a result of action that was performed by the Application B earlier. The Application A may run on a client and the Application may run on a server. To perform the call back mechanism the system that Application A runs acts as a Server and that of the Application B runs acts as a client.

    52. Question 52. Explain The Steps To Create Rmi-based Clients And Server?

      Answer :

      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

    53. Question 53. Explain The Various Methods Of Registering And Gaining Access To The Remote Object?

      Answer :

      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.

    54. Question 54. Explain How To Bind An Object To The Registry.?

      Answer :

      If an object implements the java.rmi.Remote interface, an object is to be bound to registry context. Each registry context implements the Referenceable interface.

      The object factory is implemented by the RegistryContextFactory which converts the registry references into the corresponding registry contexts or remote objects. To construct the registry constructs, the URL of the registry must be determined. In this way the remote objects will be bounded with registry contexts.

    55. Question 55. What Is Registry Service For Rmi?

      Answer :

      The registration of the remote object must be done by the server in order for the client to look it up, is called the RMI Registry. In RMI, the client must contact an RMI registry, so that the server side application will be able to contact the client’s registry which points the client in the direction of the service. The client registers the service with the registry so that it is transparent to even for the server.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Adv Java Tutorial