Java Networking - Sockets and RMI

  Home  Java Programing  Java Networking - Sockets and RMI


“Java Networking - Sockets and RMI Programming interview questions and answers.”



10 Java Networking Sockets And RMI Questions And Answers

2⟩ 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) { }

 138 views

3⟩ 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.

 145 views

4⟩ 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.

 155 views

8⟩ 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.

 132 views