What is an InetAddress? The InetAddress is Java’s representation of an IP address. Instances of this class are used together with UDP DatagramSockets and normal Socket’s and ServerSocket’s.
What are the purposes of using InetAddress class? InetAddress class provides methods to get the IP of any host name for example www.javatpoint.com, www.google.com, www.facebook.com, etc. An IP address is represented by 32-bit or 128-bit unsigned number. An instance of InetAddress represents the IP address with its corresponding host name.
What is Datagramsocket explain in detail with example? A datagram socket is the sending or receiving point for a packet delivery service. Each packet sent or received on a datagram socket is individually addressed and routed. Multiple packets sent from one machine to another may be routed differently, and may arrive in any order.
Which of the following method returns the InetAddress associated with the socket object?
Method Summary
Modifier and Type |
Method and Description |
SocketChannel |
getChannel() Returns the unique SocketChannel object associated with this socket, if any. |
InetAddress |
getInetAddress() Returns the address to which the socket is connected. |
InputStream |
getInputStream() Returns an input stream for this socket. |
What is an InetAddress? – Additional Questions
Which method of the socket module allows you to associate a host and a port with a specific socket?
bind() − This method binds the address (hostname, port number) to the socket.
Which method of ServerSocket will wait for a client to initiate communication and then communication with the client?
The server invokes the accept() method of the ServerSocket class. This method waits until a client connects to the server on the given port. After the server is waiting, a client instantiates a Socket object, specifying the server name and the port number to connect to.
Which method is used to expose the details of connection establishing between server socket and client socket?
The
ServerSocket class can be used to create a server socket. This object is used to establish communication with the clients.
Important methods.
Method |
Description |
1) public Socket accept() |
returns the socket and establish a connection between server and client. |
1 more row
Which method is used to expose the details of connection establishment between server socket and client socket Mcq?
Explanation: bind() binds the server socket to a specific address (IP Address and port).
Which methods are commonly used in server socket class in Inetaddress class which method it returns the host name of the IP address?
Explanation: In Inet Address class public String getHostname() method returns the host name of the IP Address. The getHostAddress() method returns the IP address of the given host name.
Which connection class can be used to read and write data to the specified resources that is referred by the URL?
Explanation: The URL Connection class can be used to read and write data to the specified resource referred by the URL. Datagram is basically an information but there is no guarantee of its content, arrival or arrival time.
Which function is called by a TCP server to return the next completed connection from the front of the completed connection queue?
accept Function. accept is called by a TCP server to return the next completed connection from the front of the completed connection queue (Figure 4.7).
Which of these class is used to access actual bits or content information of a URL?
5. Which of these class is used to access actual bits or content information of a URL? Explanation: URL, URLDecoder and URLConnection all there are used to access information stored in a URL.
Which class is used to create servers that listen for either local client or remote client programs?
ServerSockets class used to create servers listen for either local client or remote client programs.
Which of these classes is implemented to enable servers to accept connections from local or remote client programs?
Which of these class is used to create servers that listen for either local or remote client programs? Explanation: None.
Which of the following class is used to create a server that listen for client?
ServerSocket class is used by server applications to obtain a port and listen for client requests.
Which of these is a protocol for breaking and sending packets to an address across a network?
Which of these is a protocol for breaking and sending packets to an address across a network? Explanation: TCP/IP – Transfer control protocol/Internet Protocol is used to break data into small packets an send them to an address across a network.
Which of these class must be used to send a datagram packets over a connection?
6. Which of these class must be used to send a datagram packets over a connection? Explanation: By using 5 classes we can send and receive data between client and server, these are InetAddress, Socket, ServerSocket, DatagramSocket, and DatagramPacket.
Which of the following methods is used to avoid serialization of new class whose super class?
8. Which of the following methods is used to avoid serialization of new class whose super class already implements Serialization? Explanation: writeObject() and readObject() methods should be implemented to avoid Java serialization.
Which of these packages contain all the classes and methods required for event handling in Java?
1. Which of these packages contains all the classes and methods required for even handling in Java? Explanation: Most of the event to which an applet response is generated by a user. Hence they are in Abstract Window Kit package, java.
Which of these classes can be added to any container class using the Add method defined in container class?
You can add any JComponent object to any container class object. The class JComponent is derived from the class Container, and so you can add a JComponent to another JComponent.
Which of these packages contains all the classes and methods required for developing GUI in java *?
Hence they are in Abstract Window Kit package, java. awt. event.