Professional Documents
Culture Documents
Networking Basics
4) If your application has successfully bound to specified port and is ready for client request then_________
a) an exception is thrown b) an IOException is thrown
c) it does not throw an exception d) UnknownHostException is thrown
5) Which steps occur when establishing a TCP connection between two computers using socket?
b) The server invokes the accept() method of
a) The server initiates a ServerSocket object denoting
ServerSocket class. This method waits until a client
port number to be connected
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 d) All of the above
number
9) Which exception will occur when port is already bound with an application and other application is requesting
for same port?
a) IOException b) PortNotFoundException
c) UnknownPortNameException d) ConectException
Ans: IOException
10) Which constructor will you use to connect to specified host and port by creating a socket on the local host at
specified address & port
a) Socket() b) Socket(String host, int port)
d) Socket ( String host,int port, Inetaddress ipAdd,
c) Socket (Inetaddress ipAdd,int port)
int localport )
11) Which exception will occur if specified port number is not available for DatagramSoclet?
a) UnknownException b) SocketException
c) UnknownSocketException d) UnknownPortException
13) Unlike User Datagram Protocol (UDP), Transmission Control Protocol (TCP) has Services which is
a) Connection Oriented b) Connectionless
c) Connection Available d) Connection Origin
15) Which of these methods is used to know the full URL of an URL object?
a) fullHost() b) getHost()
c) ExternalForm() d) toExternalForm()
16) getLocalHost() method simply returns the InetAddress object which represents______________
a) host name b) machine name
c) local host d) remote host
18) getAllByName() method returns an array of_____________ that represents all of the addresses that specific
host name has
a) host names b) InetAddresses
c) ipaddresses d) objects
21) InetAddress class is used to encapsulate both numerical IP address and the ______________
a) port number b) host name
c) server name d) socket name
22) 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
23) Which of the following class is used to create server that listen for clients ?
a) httpserver b) ServerSocket
c) DatagramSocket d) Socket
24) __________method returns the local port to which the invoking socket object is bound.
a) int getLocalHost() b) int getLocalPort()
c) int getPort() d) int GetLocalHost()
29) __________________method is needed only when you instantiate the socket using the not argument
constructer.
a) bind() b) connect()
c) accept() d) SetHostName()
31) _____________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
34) __________method makes socket object no longer capable of connecting again to any server
a) send() b) wait()
c) connect() d) close()
36) Which method is used to expose the details of establishing connection between server socket & client socket ?
a) connect() b) receive()
c) there is no such method d) None of the above
37) Socket(InetAddress host, int port) in this constructor, what does first parameter stands for ?
b) host name and IPAddress specified by
a) host name
InetAddress object
c) IpAddress of host d) ipaddress and port number
40) Java DatagramSocket and DatagramPacket classes are used for _______________ socket programming
a) Connection-oriented b) Connection-less
c) A & B d) Reliable
41) Which constructor of DatagramSocket class is used to create a datagram socket and binds it with the given
port number?
a) DatagramSocket(int port) b) DatagramSoclet(int port InetAddress add)
c) DatagramSoclet() d) None of the above
43) Which of these package contains classes and interfaces for networking?
a) java.io b) java.util
c) java.net d) java.network
44) How many ports of TCP/IP are reserved for specific protocols?
a) 10 b) 1024
c) 2048 d) 512
46) How many bits value does IPv4 and IPv6 uses to represent the address?
a) 32 and 64 b) 64 and 128
c) 32 and 128 d) 64 and 64
47) __________is a server that is mediator between real web server and client application.
a) IBMServer b) SQLServer
c) ReserverSockets d) Proxy server
49) __________method is used to know the type of content used in the URL.
a) ContentType() b) Contenttype()
c) GetContentType() d) getContentType()
58) Which is a one-way communication only between the client and the server and it is not a reliable and there is
no confirmation regarding reaching the message to the destination?
a) TCP/IP b) UDP
c) Both A & B d) None of the above
61) ----- is the protocol that web browser and server use to transfer hypertext pages and images
a) FTP b) HTTP
c) telnet d) none of above
65) Which protocol is for breaking and sending packets to an address across a network.
a) UDP b) TCP/IP
c) Proxy server d) none of the above
67) Central Computer which is powerful than other computers in the network is called as __________.
a) client b) server
c) hub d) switch
68) Which of this class is used to create servers that listen for either local or remote client programs?
a) Server Machine b) Client Machine
c) HttpServer d) ServerSocket
87) Networking classes encapsulate the "socket" paradigm pioneered in the (BSD) Give the abbreviation of BSD?
a) Berkeley Software Distribution b) Berkeley Socket Distribution
c) Berkeley System Distribution d) None of the above
88) Datagrams are ------------------ of information passed between machines
a) bundles b) sets
c) none of A and B d) Both A and B
94) Which method does return true value if specified address is a multicast address ?
a) isMulticastHostName() b) isMulticastHostAddress()
c) isMulticastAddress() d) isMulticastIPAddress()
97) 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
98) Which of the following statement is correct ?
a) There are two kinds of sockets in java one is for
b) There is only one socket for server.
server and other for clients.
d) There is only one socket for server as well as for
c) There is only one socket for client.
client.
99) What happens if server socket is not able to listen on specified port ?
a) The system exits gracefully with appropriate
b) The system will wait till port is free.
message
c) IoExeption is thrown when opening the socket d) PortOccupiedException is thrown.
100) Which constructor will you use to create client socket using a preexsiting InetAddress object and a port ?
a) Socket (String hostname, int port ) b) Socket (Inetaddress ipAdd, int port )
c) Socket (Inetaddress ip Add, string Hostname) d) Socket ( int port, Inetaddress ipAdd )
101) Socket method called______returns the port number that socket is bound to on local machine
a) int getLocalPortt() b) int getPort()
c) InetAddress getInetAddress() d) string getHostAddress()
103) InetAddress class having method which returns a string that shows the host name and IP address.
a) toString() b) getHostAddress()
c) getLocalHost() d) none of the above
104) If server socket is created using serversocket () constructer then which method should we use to bind the
serve socket ?
a) isbind() b) bind()
c) bind To() d) bind ( socketAddress host , int backlog)
106) You can gain access to the input and output streams associated with socket by use getInputStream() and
a) getOutStream() b) setOutputStream()
c) getOutputStream() d) getOutputClass()
107) When you will use this ServerSocket(int port, int que) constructor to create server socket
b) to create ServerSocket with port number & Ip
a) to create ServerSocket with port number
address
c) to create ServerSocket with port number and
d) B & C
number of incoming client queue
108) Which class is used for connection-less socket programming ?
a) DatagramSocket b) DatagramServer
c) A and B d) None of the above
109) Which of the following constructor is used to create datagram socket with port number and host address
a) DatagramSoclet(int port) b) DatagramSoclet(int port InetAddress add)
c) DatagramSoclet() d) A & B
111) Datagram Packet is a message that can be used for _________ messages
a) Connection-oriented or connection less b) send and store
c) send and receive d) receive and read
113) Which of these is a protocol for breaking and sending packets to an address across a network?
a) TCP/IP b) DNS
c) Socket d) Proxy Server
118) A typical __________ program obtains a remote reference to one or more remote objects on a server and
then invokes methods on them.
a) server b) client
c) thread d) concurrent
119) Unlike Transmission Control Protocol (TCP), User Datagram Protocol (UDP) has Services which is
a) Connection Oriented b) Connectionless
c) Connection Available d) Connection Origin
122) Which of these methods is used to know when was the URL last modified?
a) LastModified() b) getLastModified()
c) GetLastModified() d) getlastModified()()
123) Which of these methods is used to know the type of content used in the URL?
a) ContentType() b) contentType()
c) getContentType() d) GetContentType()
Ans: getContentType()
128) -------- constructor specifies only a buffer that will receive data and the size of packet.
a) DatagramPacket(byte data[], int size) b) DatagramPacket(byte data[], int offset, int size)
c) DatagramPacket(byte data[], int offset, int size ,
d) All of the above
InetAddress ipAddress, int port)
129) Which of these transfer protocol must be used so that URL can be accessed by URLConnection class object?
a) http b) https
c) Any Protocol can be used d) None of the mentioned
130) In Uniform Resource Locator (URL), path is pathname of file where information is
a) Stored b) Located
c) to be transferred d) Transferred
131) The class ________is used for accessing the attributes of remote resource.
a) URI b) URLConnection
c) URL d) URLLoader
136) 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