This section of our 1000+ Java MCQs focuses on httpd.java of Java Programming Language.
1. Which of these methods of httpd class is used to read data from the stream?
Explanation: The getRawRequest() method reads data from a stream until it gets two consecutive newline characters.
2. Which of these method of httpd class is used to get report on each hit to HTTP server?
3. Which of these method is used to find a URL from the cache of httpd?
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.
4. Which of these variables stores the number of hits that are successfully served out of cache?
5. Which of these class is used for operating on request from the client to the server?
6. Which of these method of httpd class is used to write UrlCacheEntry object into local disk?
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.
7. What is the output of this program?
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();
Note: Host URL is having length of content 127.
c) Compilation Error
d) Runtime Error
$ javac networking.java $ java networking 127
8. Which of these method is used to start a server thread?
Explanation: run() method is called when the server thread is started.
9. Which of these method is called when http daemon is acting like a normal web server?
10. What is the output of this program?
public static void main(String args) throws UnknownHostException
InetAddress obj1 = InetAddress.getByName("cisco.com");
d) none of the mentioned
$ javac networking.java $ java networking cisco.com
To practice all features of Java programming language, here is complete set on 1000+ Multiple Choice Questions and Answers on Java.