250+ TOP MCQs on Networking – Server, Sockets & httpd Class and Answers

This set of Basic Java Questions and Answers on “Nnetworking – Server, Sockets & httpd Class”.

1. Which of these interface abstractes the output of messages from httpd?
a) LogMessage
b) LogResponse
c) Httpdserver
d) httpdResponse

Answer: a
Clarification: LogMessage is a simple interface that is used to abstract the output of messages from the httpd.

2. 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
Clarification: None.

3. Which of these is a standard for communicating multimedia content over email?
a) http
b) https
c) Mime
d) httpd

Answer: c
Clarification: MIME is an internet standard for communicating multimedia content over email. The HTTP protocol uses and extends the notion of MIME headers to pass attribute pairs between HTTP client and server.

4. Which of these methods is used to make raw MIME formatted string?
a) parse()
b) toString()
c) getString()
d) parseString()

Answer: a
Clarification: None.

5. 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
Clarification: None.

6. 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
Clarification: toString() does the reverse of parse() method, it is used to return the string equivalent of the values stores on MimeHeader.

  250+ TOP MCQs on Class Fundamentals & Declaring objects and Answers

7. What will be the output of the following Java program?

  1.     import java.net.*;
  2.     class networking 
  3.     {
  4.         public static void main(String[] args) throws Exception 
  5.         {
  6.             URL obj = new URL("javamcq");
  7.             URLConnection obj1 = obj.openConnection();
  8.             System.out.print(obj1.getContentType());
  9.         }
  10.     }

Note: Host URL is written in html and simple text.
a) html
b) text
c) html/text
d) text/html

Answer: d
Clarification: None.
Output:

$ javac networking.java
$ java networking 
text/html

8. Which of these is an instance variable of class httpd?
a) port
b) cache
c) log
d) All of the mentioned

Answer: d
Clarification: There are 5 instance variables: port, docRoot, log, cache and stopFlag. All of them are private.

9. What will be the output of the following Java program?

  1.     import java.net.*;
  2.     class networking 
  3.     {
  4.         public static void main(String[] args) throws MalformedURLException 
  5.         {
  6.             URL obj = new URL("javamcq");
  7.             System.out.print(obj.toExternalForm());
  8.         }
  9.     }

a)
b) .com
c) www..com
d) javamcq

Answer: d
Clarification: toExternalForm() is used to know the full URL of an URL object.
Output:

$ javac networking.java
$ java networking 
https://www..com/javamcq

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top