0% found this document useful (0 votes)
7 views17 pages

Chapter3QB

The document consists of a series of multiple-choice questions and answers related to networking concepts, including server processes, Internet addressing, URL handling, and socket programming. Key topics covered include the use of protocols like TCP/IP, methods for handling URLs, and classes used in Java for networking. Each question is followed by the correct answer, providing a quick reference for understanding networking fundamentals.

Uploaded by

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

Chapter3QB

The document consists of a series of multiple-choice questions and answers related to networking concepts, including server processes, Internet addressing, URL handling, and socket programming. Key topics covered include the use of protocols like TCP/IP, methods for handling URLs, and classes used in Java for networking. Each question is followed by the correct answer, providing a quick reference for understanding networking fundamentals.

Uploaded by

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

1.

To manage multiple client connections a server process must be -------------


a) Multiported.
b) Effective.
c) Efficient.
d) Multithreaded.
ANSWER: d
2. Nowadays we are using ----------- version of Internet addressing
a) IPV2.
b) IPV3.
c) IPV4.
d) IPV5.
ANSWER: c
3. Default value for Server Socket constructor is ----------
a) 50.
b) 60.
c) 70.
d) 80.
ANSWER: a
4. Datagram provides an alternative for -----------
a) IP.
b) TCP.
c) TCP/IP.
d) UDP.
ANSWER: c
5. If sockets have been invalidated ---------- are used to send and receive data.
a) IP stream.
b) TCP.
c) UDP.
d) I/O stream.
ANSWER: d
6. Which datagram method returns the byte array of data contained in the
datagram?
a) InetAddressgetAddress().
b) intgetPort().
c) byte[] getData().
d) byte[] getAddress().
ANSWER: c
7. ________method returns the length of data contained in the byte array.
a) getLength().
b) getLengthOf().
c) getDataLength().
d) getDataLengthOf().
ANSWER: a
8. What does URL stands for?
a) Uniform Resource Locator
b) Uniform Resource Latch
c) Universal Resource Locator
d) Universal Resource Latch
ANSWER: a
9.Which of these exception is thrown by URL class’s constructors?
a) URLNotFound
b) URLSourceNotFound
c) MalformedURLException
d) URLNotFoundException
ANSWER: c
10. Which of these methods is used to know host of an URL?
a) host()
b) getHost()
c) GetHost()
d) gethost()
ANSWER: b
11.Which of these methods is used to know the full URL of an URL object?
a) fullHost()
b) getHost()
c) ExternalForm()
d) toExternalForm()
ANSWER: d
12.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
ANSWER: d
13. Which of these class is used to encapsulate IP address and DNS?
a) DatagramPacket
b) URL
c) InetAddress
d) ContentHandler
ANSWER: c
14. What is the output of this program?
import java.net.*;
class networking
{
public static void main(String[] args) throws MalformedURLException {
URL obj = new URL("http://www.sanfoundry.com/javamcq");
System.out.print(obj.getProtocol());
}
}
a) http
b) https
c) www
d) com
ANSWER: a
15. What is the output of this program?
import java.net.*;
class networking
{
public static void main(String[] args) throws MalformedURLException {
URL obj = new URL("http://www.sanfoundry.com/javamcq");
System.out.print(obj.getPort());
}
}

a) 1
b) 0
c) -1
d) garbage value
ANSWER: c
16. What is the output of this program?
import java.net.*;
class networking
{
public static void main(String[] args) throws MalformedURLException {
URL obj = new URL("http://www.sanfoundry.com/javamcq");
System.out.print(obj.getHost());
}
}
a) sanfoundry
b) sanfoundry.com
c) www.sanfoundry.com
d) http://www.sanfoundry.com/javamcq
ANSWER: c

17. What is the output of this program?


import java.net.*;
class networking
{
public static void main(String[] args) throws MalformedURLException {
URL obj = new URL("http://www.sanfoundry.com/javamcq");
System.out.print(obj.toExternalForm());
}
}

a) sanfoundry
b) sanfoundry.com
c) www.sanfoundry.com

d) d)http://www.sanfoundry.com/javamcq
ANSWER: d
18. Which of these is wrapper around everything associated with a reply from an
http server?
a) HTTP
b) HttpResponse
c) Httpserver
d) httpserver
ANSWER: a
19. Which of these tranfer 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
ANSWER: a
20. Which of these methods is used to know when was the URL last modified?
a) LastModified()
b) getLastModified()
c) GetLastModified()
d) getlastModified()()
ANSWER: b
21. Which of these methods is used to know the type of content used in the URL?
a) ContentType()
b) contentType()
c) getContentType()
d) GetContentType()
ANSWER: c
22. Which of these data member of HttpResponse class is used to store the
response from a http server?
a) status
b) address
c) statusResponse
d) statusCode
ANSWER: d
23. What is the output of this program?
import java.net.*;
class networking
{
public static void main(String[] args) throws Exception
{
URL obj = new URL("http://www.sanfoundry.com/javamcq");
URLConnection obj1 = obj.openConnection();
intlen = obj1.getContentLength();
System.out.print(len);
}
}
Note: Host URL is having length of content 127.

a) 126
b) 127
c) Compilation Error
d) Runtime Error
ANSWER: b
24. What is the output of this program?
import java.net.*;
class networking
{
public static void main(String[] args) throws Exception
{
URL obj = new URL("http://www.sanfoundry.com/javamcq");
URLConnection obj1 = obj.openConnection();
System.out.print(obj1.getLastModified);
}
}
Note: Host URL was last modified on july 18 tuesday2013 .

a) july
b) 18-6-2013
c) Tue 18 Jun 2013
d) Tue Jun 18 2013
ANSWER: d
25. Which of these methods of httpd class is used to read data from the stream?
a) getDta()
b) GetResponse()
c) getStream()
d) getRawRequest()
ANSWER: d
26. Which of these method of httpd class is used to get report on each hit to
HTTP server?
a) log()
b) logEntry()
c) logHttpd()
d) logResponse()
ANSWER: b
27. Which of these method is used to find a URL from the cache of httpd?
a) findfromCache()
b) findFromCache()
c) serveFromCache()
d) getFromCache()
ANSWER: c
28.Which of these variables stores the number of hits that are successfully served
out of cache?
a) hits
b) hitstocache
c) hits_to_cache
d) hits.to.cache
ANSWER: d
29.Which of these class is used for operating on request from the client to the
server?
a) http
b) httpDecoder
c) httpConnection
d) httpd
ANSWER: d
30. Which of these method of httpd class is used to write UrlCacheEntry object into
local disk?
a) writeDiskCache()
b) writetoDisk()
c) writeCache()
d) writeDiskEntry()
ANSWER: a
31. Which of these method is used to start a server thread?
a) run()
b) start()
c) runThread()
d) startThread()
ANSWER: a
32. Which of these method is called when http daemon is acting like a normal web
server?
a) Handle()
b) HandleGet()
c) handleGet()
d) Handleget()
ANSWER: c
33. What is the output of this program?
import java.net.*;
class networking
{
public static void main(String[] args) throws UnknownHostException
{
InetAddress obj1 = 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
34. Which of these is a bundle of information passed between machines?
a) MIME
b) cache
c) Datagrams
d) DatagramSocket
ANSWER: __
35. Which of these class is necessary to implement datagrams?
a) DatagramPacket
b) DatagramSocket
c) Both of the mentioned
d) None of the mentioned
ANSWER: c
36. Which of these method of DatagramPacket is used to find the port number?
a) port()
b) getPort()
c) findPort()
d) recievePort()
ANSWER: a
37. Which of these method of DatagramPacket is used to obtain the byte array of
data contained in a datagram?
a) getData()
b) getBytes()
c) getArray()
d) recieveBytes()
ANSWER: a
38. Which of these method of DatagramPacket is used to find the length of byte
array?
a) getnumber()
b) length()
c) Length()
d) getLength()
ANSWER: d
39. Which of these class must be used to send a datatgram packets over a
connection?
a) InetAdress
b) DatagramPacket
c) DatagramSocket
d) All of the mentioned
ANSWER: d
40.What is the output of this program?
import java.net.*;
class networking
{
public static void main(String[] args) throws Exception
{
URL obj = new URL("http://www.sanfoundry.com/javamcq");
URLConnection obj1 = obj.openConnection();
System.out.print(obj1.getContentType());
}
}
Note: Host URL is written in html and simple text.
a) html
b) text
c) html/text
d) text/html
ANSWER: d
41. Which of these method of DatagramPacket class is used to find the
destination address?
a) findAddress()
b) getAddress()
c) Address()
d) whois()
ANSWER: b
42. Which of these is a return type of getAddress method of DatagramPacket
class?
a) DatagramPacket
b) DatagramSocket
c) InetAddress
d) ServerSocket
ANSWER: c
43. GET methods are great for sending ....................amounts of information that you
do not mind having visible in a URL.
a) negligible
b) huge
c) small
d) both and b
ANSWER: c
44. What is sent to the user via HTTP, invoked using the HTTP protocol on the user's
computer, and run on the user's computer as an application?
a) A Java application
b) A Java applet
c) A Java servlet
d) None of the above is correct.
ANSWER: b
45. Which of these interface abstractes the output of messages from httpd?
a) LogMessage
b) LogResponse
c) Httpdserver
d) httpdResponse
ANSWER: a
46. Which of these class is used to create servers that listen for either local or
remote client programs?
a) httpServer
b) ServerSockets
c) MimeHeader
d) HttpResponse
ANSWER: b
47. Which of these is a standard for communicating multimedia content over
email?
a) HTTP
b) HTTPS
c) MIME
d) HTTPD
ANSWER: c
48.Which of these methods is used to make raw MIME formatted string?
a) parse()
b) toString()
c) getString()
d) parseString()
ANSWER: a
49. Which of these class is used for operating on request from the client to the
server?
a) http
b) httpDecoder
c) httpConnection
d) httpd
ANSWER: d
50. Which of these method of MimeHeader is used to return the string equivalent of
the values stores on MimeHeader?
a) string()
b) toString()
c) convertString()
d) getString()
ANSWER: b
51. Which of these is an instance variable of class httpd?
a) port
b) cache
c) log
d) All of the mentioned
ANSWER: d
52. Which of these is an instance variable of httpd that is a Hashtable?
a) port
b) cache
c) log
d) stopFlag
ANSWER: c
53. What is the output of this program?
import java.net.*;
class networking
{
public static void main(String[] args) throws UnknownHostException
{
InetAddress obj1 = 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

54. Show some networking terminologies given below?


a. IP Address
b. Protocol
c. MAC Address
d. All mentioned above
ANSWER: d) All mentioned above
55. TCP,FTP,Telnet,SMTP,POP etc. are examples of ?
a. Socket
b. IP Address
c. Protocol
d. MAC Address
ANSWER: C) Protocol
56. Which classes are used for connection-oriented socket programming?
a. Socket
b. ServerSocket
c. Both A & B
d. None of the above

ANSWER: c) Both a & b


57. Which class can be used to create a server socket. This object is used to
establish communication with the clients?
a. ServerSocket
b. Socket
c. Both A & B
d. None of the above
ANSWER: a) ServerSocket
58. Which methods are commonly used in ServerSocket class?
a. public OutputStreamgetOutputStream()
b. public Socket accept()
c. public synchronized void close()
d. None of the above
ANSWER: B) public Socket accept()

59. The web server then responds back to the _____________ accordingly:
a) Web browser
b) Web server
c) Server
d) All of these
ANSWER: a
60. It specifies the name of host issuing request:
a) REMOTE_HOST
b) REMOTE HOST
c) Remote_host
d) None of these
Answer: a

You might also like