642). Which of these methods of httpd class is used to read data from the stream?
[A] getDta()
[B]GetResponse()
[C]getStream()
[D]getRawRequest()
Show Answer
Correct Answer: getRawRequest()
Notes:
Answer: d
Explanation: The getRawRequest() method reads data from a stream until it gets two consecutive newline characters.
643). 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()
Show Answer
Correct Answer: logEntry()
Notes:
Answer: b
Explanation: None.
644). Which of these methods are used to find a URL from the cache of httpd?
[A]findfromCache()
[B] findFromCache()
[C]serveFromCache()
[D]getFromCache()
Show Answer
Correct Answer: serveFromCache()
Notes:
Answer: c
Explanation: serveFromCatche() is a boolean method that attempts to find a particular URL in the cache. If it is successful then the content of that cache entry are written to the client, otherwise it returns false.
645). 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
Show Answer
Correct Answer: hits.to.cache
Notes:
Answer: d
Explanation: None.
646). Which of these method of httpd class is used to write UrlCacheEntry object into local disk?
[A]writeDiskCache()
[B]writetoDisk()
[C]writeCache()
[D]writeDiskEntry()
Show Answer
Correct Answer: writeDiskCache()
Notes:
Answer: a
Explanation: The writeDiskCache() method takes an UrlCacheEntry object and writes it persistently into the local disk. It constructs directory names out of URL, making sure to replace the slash(/) characters with system dependent seperatorChar.
647). What will be the output of the following Java program?
import java.net.*;
class networking
{
public static void main(String[] args) throws Exception
{
URL obj = new URL("https://www.sanfoundry.com/javamcq");
URLConnection obj1 = obj.openConnection();
int len = obj1.getContentLength();
System.out.print(len);
}
}
[A]126
[B]127
[C]Compilation Error
[D]Runtime Error
Show Answer
Correct Answer: 127
Notes:
Answer: b
Explanation: None.
Output:$ javac networking.java
$ java networking
127
648). Which of these method is used to start a server thread?
import java.net.*;
class networking
{
public static void main(String[] args) throws Exception
{
URL obj = new URL("https://www.sanfoundry.com/javamcq");
URLConnection obj1 = obj.openConnection();
int len = obj1.getContentLength();
System.out.print(len);
}
}
[A]run()
[B]start()
[C]runThread()
[D]startThread()
Show Answer
Correct Answer: run()
Notes:
Answer: a
Explanation: run() method is called when the server thread is started.
649). Which of these method is called when http daemon is acting like a normal web server?
import java.net.*;
class networking
{
public static void main(String[] args) throws Exception
{
URL obj = new URL("https://www.sanfoundry.com/javamcq");
URLConnection obj1 = obj.openConnection();
int len = obj1.getContentLength();
System.out.print(len);
}
}
[A]Handle()
[B]HandleGet()
[C] handleGet()
[D]Handleget()
Show Answer
Correct Answer: handleGet()
Notes:
Answer: c
Explanation: None.