Ajp Unit 4
Ajp Unit 4
Networking Basics
Q1. getLocalHost() method simply returns the InetAddress object which represents
Q3. getAllByName() method returns an array of that represents all of the addressesthat
specific host name has
Q5. what is the output of following program import java.net.*; class Demo { public static
void main(String arg[]) { InetAddress ip=InetAddress.getByName("www.google.com");
System.out.println(ip) }
A) www.google.com/217.56.216.195 B)
www.google.com C) 217.56.216.195 D)
All of the above
B) Returns a byte array that represents the object's Ip address in the network
byte order.
Q7. Type of server in two-tier architectures which provides data to client stored on disk pages
iscalled
A) transaction server B) functional server C) disk server D) data
server
Q8. Which method does return true value if specified address is a multicast address ?
A) isMulticastHostName() B) isMulticastHostAddress()
C) isMulticastAddress() D)
isMulticastIPAddress()
InetAddress ip=InetAddress.getLocalHost();
System.out.println(ip.getHostAddress();
A) 192.168.0.100 B) localhost/192.168.0.100
C) localhost machine D) localhost//8080:
Q11. InetAddress class is used to encapsulate both numerical IP address and the
Q12. You can simply use InetAddress class when working with IP address because it can
accommodate both styles.
A) IP4V and IP6V B) IPV4 and IPV6 C) host name and IP D) A and
B
D) Returns astring that represents a host name associated with Inetaddress object.
Q14. getHostName() of InetAddress class is used to
A) Return a string that represents host name associated with Inetaddress object.
B) Return a string that represents host address associated with Inetaddress object.
A) There are two kinds of sockets in java one is for server and other for clients.
Q16. Which of the following class is used to create server that listen for clients ?
Q17. What happens if server socket is not able to listen on specified port ?
D) PortOccupiedException is thrown.
Q18. Which exception will be thrown if client socket does not specify the hostname when it
has created?
A) IOException B) UnknownHostException
C) UnknownHostNameException D) UnknownPortException
Q19. Which constructor will you use to create client socket using a preexsiting InetAddress
object anda port ?
Q20. method returns the local part to which the invoking socket object is bound.
A) int getLocalHost() B) int getLocalPort()
C) int getPort() D) int
GetLocalHost()
C) stringgetHostName()
D) A and B
Q24. Socket method called returns the port number that socket is bound to on local
machine
Q27. method is needed only when you instantiate the socket using the not argument
constructer.
Q28. InetAddress class having method which returns a string that shows the host name and IP
address.
Q31. Class represents the socket that both the client & server use to communicate with each
other
A) java.net.Serversocket B) java.net.Server
C) Java.net.socket D) java.net.Clientsocket
B) Client socket is created to connect with specified host name and port number
inta=s1.getPort();
System.out.println(a);
Sockets1=ss.accept();
System.out.println(ss.getLocalPort());
A) port number of client socket B) 1349 C) local port D) None of
the above
A) The input stream of socket is connected to the output stream of remote socket
B) The output stream ofsocket is connected to the input stream of remote socket
C) The output stream of socket is connected to the output stream of remote socket
D) A and B
Q39. method makes socket object no longer capable of connecting again to any server
Q40. If your application has successfully bound to specified port and is ready for client
requestthen
Q42. Which steps occur when establishing a TCP connection between two computers using
socket?
B) The server invokesthe accept() method of ServerSocket class. This method waits
until a client connects to the server on the given port
C) After the server is waiting, a client instantiates a socket object with specified
server name and port number
Sockets1=ss.accept();
System.out.println(s1.getPort());
Sockets1=ss.accept();
System.out.println(s1.getRemoteSocketAddress());
A) 1234 B) iPAddress of
serversocket C) IPAddress of client with port number D) IPAddress of
serverwith port number
System.out.println(s1.getRemoteSocketAddress());
Q47. Which method is used to expose the details of establishing connection between server
socket &client socket ?
A) getOutStream() B) setOutputStream()
C) getOutputStream() D)
getOutputClass()
Q49. Which exception will occur when port is already bound with an application and other
application isrequesting for same port?
A) IOException B)
PortNotFoundException C) UnknownPortNameException
D) ConectException
Q50. When you will use this ServerSocket(int port, int que) constructor to create server
socket
C)to create ServerSocket with port number and number of incoming client
queue
D) B & C
Q51. Socket(InetAddress host, int port) in this constructor, what does first parameter stands
for ?
Q52. Which constructor will you use to connect to specified host and port by creating a
socket on thelocal host at specified address & port
Q56. Which constructor of DatagramSocket class is used to create a datagram socket and
binds it withthe given port number?
Q58. Which exception will occur if specified port number is not available for
DatagramSoclet?
A) UnknownException B) SocketException
C) UnknownSocketException D)
UnknownPortException
Q59. ) Which of the following constructor is used to create datagram socket with port number
and hostaddress
Q61. Java DatagramSocket and DatagramPacket classes are used for socket
programming
Q67. Which of these package contains classes and interfaces for networking?
Q68. Which of these is a protocol for breaking and sending packets to an address across a
network?
Q69. How many ports of TCP/IP are reserved for specific protocols?
A) 10 B) 1024 C) 2048 D)
512
A) 8 B) 16 C) 32 D) 64
Q71. How many bits value does IPv4 and IPv6 uses to represent the address?
Q73. is a server that is mediator between real web server and client application.
Q75. method is used to know the type of content used in the URL.
A) URLNotFound B) URLSourceNotFound
C) MalformedURLException D)
URLNotFoundException
Q84. Which of these class is used to access actual bits or content information of a URL?
A) URL B) URLDecoder C) URLConnection D) All of
the mentioned
import java.net.*;
class networking
System.out.print(obj.getProtocol());
Q86. Which of these methods is used to know the full URL of an URL object?
Q88. Which of these methods is used to know when was the URL last modified?
A) LastModified() B) getLastModified()
C) GetLastModified() D)
getlastModified()()
import java.net.*;
class networking
{
URL obj = new URL("https://www.sanfoundry.com/javamcq");
System.out.print(obj1.getContentType());
A) UnknownHostException B)
MalformedURLExeption C) Exception
D) All of the above
Q94. _______ constructor specifies only a buffer that will receive data and the size of
packet.
C) DatagramPacket(byte data[], int offset, int size , InetAddress ipAddress, int port)
import java.net.*;
class networking
System.out.print(obj.getPort());
A) 1 B) 0 C) -1 D) garbage value
Q97. Which steps occur when establishing a TCP connection between two computers using
sockets?
Q98. Which of these transfer protocol must be used so that URL can be accessed by
URLConnectionclass object?
A) http B) https
C) Any Protocol can be used D) None of the
mentioned
Q99. The class is used for accessing the attributes of remote resource.
A) 1 B) 2 C) 3 D) 4