Chapter3QB
Chapter3QB
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
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
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