Java MCQs on httpd.java of Java Programming Language.
1. Which of these methods of httpd class is used to read data from the stream? Answer: d 2. Which of these method of httpd class is used to get report on each hit to HTTP server? Answer: b 3. Which of these methods are used to find a URL from the cache of httpd? Answer: c 4. Which of these variables stores the number of hits that are successfully served out of cache? Answer: d 5. Which of these method of httpd class is used to write UrlCacheEntry object into local disk? Answer: a 6. What will be the output of the following Java program? Note: Host URL is having length of content 127. 7. Which of these method is used to start a server thread? Answer: a 8. Which of these method is called when http daemon is acting like a normal web server? Answer: c
a) getDta()
b) GetResponse()
c) getStream()
d) getRawRequest()
Clarification: The getRawRequest() method reads data from a stream until it gets two consecutive newline characters.
a) log()
b) logEntry()
c) logHttpd()
d) logResponse()
Clarification: None.
a) findfromCache()
b) findFromCache()
c) serveFromCache()
d) getFromCache()
Clarification: 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.
a) hits
b) hitstocache
c) hits_to_cache
d) hits.to.cache
Clarification: None.
a) writeDiskCache()
b) writetoDisk()
c) writeCache()
d) writeDiskEntry()
Clarification: 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.
import java.net.*;
class networking
{
public static void main(String[] args) throws Exception
{
URL obj = new URL("javamcq");
URLConnection obj1 = obj.openConnection();
int len = obj1.getContentLength();
System.out.print(len);
}
}
a) 126
b) 127
c) Compilation Error
d) Runtime Error
Clarification: None.
Output:
$ javac networking.java
$ java networking
127
a) run()
b) start()
c) runThread()
d) startThread()
Clarification: run() method is called when the server thread is started.
a) Handle()
b) HandleGet()
c) handleGet()
d) Handleget()
Clarification: None.