0% found this document useful (0 votes)
24 views6 pages

Chap4 Networking 2

Uploaded by

patilvashra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views6 pages

Chap4 Networking 2

Uploaded by

patilvashra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

(c) Protocol

Networking and Security (d) MAC Address


1. TCP, FTP, Telnet, SMTP, POP etc. are examples ANSWER: B
of?
(a) Socket 8. In InetAddress class which method it returns
(b) IP Address the host name of the IP Address?
(c) Protocol (a) public String getHostName()
(d) MAC Address (b) public String getHostAddress()
ANSWER: C (c) public static InetAddress getLocalHost()
(d) None of the above
2. Which classes are used for connection-oriented ANSWER: A
socket programming?
(a) Socket 9. Which classes are used for connection-less
(b) ServerSocket socket programming?
(c) Both (a) and (b) (a) DatagramSocket
(d) None of the above (b) DatagramPacket
ANSWER: C (c) Both (a) and (b)
(d) None of the above
3. Which class can be used to create a server ANSWER: C
socket. This object is used to establish
communication with the clients? 10. Which class is message that can be sent or
(a) ServerSocket received. If you send multiple packet, it may
(b) Socket arrive in any order. Moreover, packet delivery
(c) Both (a) and (b) is not guaranteed?
(d) None of the above (a) DatagramPacket
ANSWER: A (b) DatagramSocket
(c) Both (a) and (b)
4. Which methods are commonly used in (d) None of the above
ServerSocket class? ANSWER: A
(a) public OutputStream getOutputStream()
(b) public Socket accept() 11. Which constructor of DatagramSocket class is
(c) public synchronized void close() used that it creates a datagram socket and
(d) None of the above binds it with the given Port Number?
ANSWER: B (a) DatagramSocket(int port)
(b) DatagramSocket(int port, InetAddress
5. URL is an acronym for? address)
(a) Uniform Resource Locator (c) DatagramSocket()
(b) Unified Resource Locator (d) None of the above
(c) Uniform Restore Locator ANSWER: B
(d) Unified Restore Locator
ANSWER: A 12. Which steps occur when establishing a TCP
connection between two computers using
6. The URLConnection class can be used to read sockets?
and write data to the specified resource (a) The server instantiates a ServerSocket object,
referred by the URL? denoting which port number communication is
(a) True to occur on
(b) False (b) The server invokes the accept() method of
ANSWER: A the ServerSocket class. This method waits until a
client connects to the server on the given port.
7. The java.net.InetAddress class represents an? (c) After the server is waiting, a client
(a) Socket instantiates a Socket object, specifying the
(b) IP Address server name and port number to connect to.
(d) All of the above. 19. Which of these package contains classes and
ANSWER: D interfaces for networking?
(a) java.io
13. The flush() method of PrintStream class flushes (b) java.util
any uncleared buffers in memory? (c) java.net
(a) True (d) java.network
(b) False ANSWER: C
ANSWER: A
20. Which of these methods is used to know when
14. Which method of URL class represents a URL was the URL modified?
and has complete set of methods to (a) LastModified()
manipulate URL in Java? (b) getLastModified()()
(a) java.net.URL (c) GetLastModified()
(b) java.net.URLConnection (d) getlastModified()
(c) Both (a) and (b) ANSWER: D
(d) None of the above
ANSWER: A 21. Which of these is a protocol for breaking and
sending packets to an address across a
15. These networking classes encapsulate the network?
"socket" paradigm pioneered in the (BSD) Give (a) TCIP/IP
the abbreviation of BSD? (b) DNS
(a) Berkeley Software Distribution (c) Socket
(b) Berkeley Socket Distribution (d) proxy server
(c) Berkeley System Distribution ANSWER: A
(d) None of the above
ANSWER: B 22. Which of these class is used to encapsulate IP
address and DNS?
16. Which class is used to create servers that listen (a) DatagramPacket
for either local client or remote client (b) URL
programs? (c) InetAddress
(a) ServerSockets (d) Contenhandler
(b) httpServer ANSWER: C
(c) httpResponse
(d) None of the above 23. In this constructor ServerSocket(int port, int
ANSWER: A maxQueue) what is the default value for
maxQueue?
17. In OSI network architecture, the dialogue (a) 100
control and token management are (b) 50
responsibilities of (c) 75
(a) Network (d) 80
(b) Session ANSWER: B
(c) Application
(d) DataLink 24. How many ports of TCP/IP are reserved for
ANSWER: B specific protocols?
(a) 10
18. In OSI network architecture, the routing is (b) 1024
performed by (c) 2048
(a) Network (d) 512
(b) Sessiorn ANSWER: B
(c) Application
(d) DataLink 25. Which of these package contains classes and
ANSWER: B interfaces for networking?
(a) java.io (c) the client is blocked until the port is
(b) java.util available.
(c) java.net (d) the client encounters a fatal error and must
(d) java.network be terminated.
ANSWER: C ANSWER: A

26. Which of these is a protocol for breaking and 32. The client requests a connection to a server
sending packets to an address across a using the following statement:
network? (a) Socket s = new Socket(ServerName, port);
(a) TCIP/IP (b) Socket s = serverSocket.accept();
(b) DNS (c) Socket s = serverSocket.getSocket();
(c) Socket (d) Socket s = new Socket(ServerName);
(d) Proxy Server ANSWER: A
ANSWER: A
33. The server listens for a connection request
27. Which of these is a full form of DNS? from a client using the following statement:
(a) Data Network Service (a) Socket s = new Socket(ServerName, port);
(b) Data Name Service (b) Socket s = serverSocket.accept();
(c) Domain Network Service (c) Socket s = serverSocket.getSocket();
(d) Domain Name Service (d) Socket s = new Socket(ServerName);
ANSWER: D ANSWER: B

28. Which of these class is used to encapsulate IP 34. When a client requests connection to a server
address and DNS? that has not yet started, _______
(a) DatagramPacket (a) java.net.BindException occurs.
(b) URL (b) java.net.ConnectionException occurs.
(c) InetAddress (c) the client is blocked until the server is
(d) ContentHandler started
ANSWER: C (d) the client encounters a fatal error and must
be terminated.
29. How many bits are in a single IP address? ANSWER: B
(a) 8
(b) 16 35. To create an InputStream on a socket s, you
(c) 32 use ______
(d) 64 (a) InputStream in = new InputStream(s);
ANSWER: C (b) InputStream in = s.getInputStream();
(c) InputStream in = s.obtainInputStream();
30. When creating a server on a port that is (d) InputStream in = s.getStream();
already in use, _______ ANSWER: B
(a) java.net.BindException occurs.
(b) the server is created with no problems. 36. _________ models an IP address, which can be
(c) the server is blocked until the port is used to find the host name and IP address of
available. the client.
(d) the server encounters a fatal error and must (a) TheServerSocket class
be terminated. (b) The Socket class
ANSWER: A (c) ThelnetAddress class
(d) The Connection interface
31. When creating a client on a server port that is ANSWER: C
already in use, _____
(a) the client can connect to the server 37. To connect to a server running on the same
regardless of whether the port is in use. machine with the client, which of the
(b) java.net.BindException occurs. following can be used for the hostname?
(a) “localhost" ANSWER: B
(b) “127.0.0.1"
(c) InetAddress.getLocalHost() 42. To obtain an ObjectOutputStream from a
(d) All of above socket, use
ANSWER: D (a) socket.getOutputStream()
(b) socket.getObjectStream()
38. The _______ method in the InetAddress class (c) new
returns the IP address. ObjectOutputStream(socket.getOutputStream()
(a) getIP() )
(b) getIPAddress() (d) socket.objectOutputStream()
(c) getHostAddress() ANSWER: C
(d) getAddress()
ANSWER: C 43. To obtain an ObjectInputStream from a
socket, use
39. A ServerSocket can connect to ______ clients. (a) socket.getInputStream()
(a) one (b) socket.getObjectStream()
(b) two (c) socket.getObjectInputStream))
(c) ten (d) new
(d) an unlimited number of ObjectInputStream(socket.getInputStream())
ANSWER: D ANSWER: D

40. You can invoke ______ on a Socket object, say


socket, to obtain an InetAddress object.
a) socket.InetAddress();
(b) socket.getInetAddress();
(c) socket.obtainInetAddress();
(d) socket.retrievelnetAddress():
ANSWER: B

41. You can obtain the server's hostname by


invoking _______ on an applet.
(a) getCodeBase().host()
(b) getCodeBase().getHost()
(c) getCodeBase().hostName()
(d) getCodeBase().getHostName()

Networking and Security (Application Level)


1. What is the output of this program?
import java.net.*;
class networking
{
public static void main (String []args)throws UnknownHostException
{
InetAddress objl = InetAddress.getByName("cisco.com")
System.out.print(obj1.getHostName());
}
}
(a) cisco
(b) cisco.com
(c) www.cisco.com
(d) None of the mentioned
ANSWER: B

2. What is the output of this program?


import java.net.*;
class networking
{
public static void main(String []args) throws UnknownHostException
{
InetAddress objl = InetAddress.getByName ("sanfoundary.com");
InetAddress obj2 = InetAddress.getByName("sanfoundary.com");
boolean x = obj1.equals(obj2);
System.out.print(x);
}
}
(a) 0
(b) 1
(c) true
(d) false
ANSWER: C

3. What will be the output of above code?


import java.net.*;
public class URLDemo
{
public static void main (String args{ })throws MalformedURLException
{
URL hp = new URL ("http://www.javajazzup.com");
System.out.println ("Protocol:"+ hp.getProtocol());
System.out.println ("Port:" + hp.getPort ());
System.out.println ("Host:" + hp.getHost ());
System.out.println ("File:" + hp.getFile ());
System.out.println ("Ext:" + hp.toExternalForm());
}
}
(a) Protocol:http
Port:-1
Host:www.javajazzup.com
File:
Ext:http:/www.javajazzup.com
(b) Protocol:http
Port:-1
Host:www.//javajazzup.com
File: javajazzup
Ext:http:/www.javajazzup.com
(c) Protocol:http
Port:80
Host:www.//javajazzup.com
File:
Ext:http:/www.javajazzup.com
(d) Protocol:http
Port:-1
Host:www.javajazzup.com
File
Ext:www.javajazzup.com
ANSWER: B
4. What is the error in given code?
import java.net.*;
public class Hostname
{
public static void main (String args[])
{
try
{
InetAddress local= InetAddress.getLocalHost();
System.out.println ("Local hostname is: "+
local.getLocalHost Name ());
}
catch (UnknownHostException e)
{
System.err.println ("Can't detect localhost: ” + e);
}
}
}
(a) No error
(b) Class name is wrong
(c) InetAddress local= InetAddress.getLocalHost(); statement is wrong
(d) System.out.println ("Local hostname is: " + local.getLocalHostName()); is wrong
ANSWER: D

5. What is the error in given code?


import java.net.*;
public class IPReverseTest
{
public static void main (String[] args)
{
try
{
InetAddress ia = InetAddress.getByName ("192.168.10.105")
System.out.println(ia.getHostName ());
}
catch (Exception ex)
{
System.err.println("does not fine hostname");
}
}
}
(a) InetAddress ia = InetAddress.getByName("192.168.10.105");
(b) System.out.println(ia.getHostName());
(c) both (a) and (b)
(d) No Error
ANSWER: D

You might also like