The largest Interview Solution Library on the web


Interview Questions
« Previous | 0 | 1 | 2 | 3 | 4 | Next »

21.What is the difference between URL instance and URLConnection instance?

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.How do I make a connection to URL?

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.What Is a Socket in Java Networking and RMI?

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.What information is needed to create a TCP Socket?

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

25.What are the two important TCP Socket classes?

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.When MalformedURLException and UnknownHostException throws?

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.What does RMI stand for?

It stands for Remote Method Invocation.

28.What is RMI?

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.What is the difference between the File and RandomAccessFile classes?

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.What interface must an object implement before it can be written to a stream as an object?

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

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

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

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

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

• 1
• 2
• 3
• 4
• 5
• 6
• 7

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

36.Does RMI-IIOP support dynamic downloading of classes?

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.

37.Can RMI and Corba based applications interact ?

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

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

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

40.Explain the difference between RPC and RMI?

RMIRPC
The remote objects are accessed by the referencesThe process is through methods / functions
Implements object to object implementation among different java objects to implement distributed communication modelProxy server is involved in processing the procedure calls
RMI passes the objects as parameters to remote methods.Calls a procedure remotely like invoking the methods
RMI invokes the remote methods from the objectsThe remoteness is not exactly transparent to the client

« Previous | 0 | 1 | 2 | 3 | 4 | Next »


copyright © 2014 - all rights riserved by javatechnologycenter.com