Java Socket Programming Questions and Answers With PDF

Java Programming : Java Socket Programming

Here is the collection of all Java Socket Programming Interview Questions and Answers. You can also download the PDF for Socket Programming Questions

1. Which of these interface abstractes the output of messages from httpd?
[A] LogMessage
[B] LogResponse
[C] Httpdserver
[D] httpdResponse

Answer: A. LogMessage

Explanation:

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. ServerSockets

Explanation:

None
3. Which of these is a standard for communicating multimedia content over email?
[A] http
[B] https
[C] Mime
[D] httpd

Answer: C. Mime

Explanation:

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. parse()

Explanation:

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. httpd

Explanation:

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. toString()

Explanation:

toString() does the reverse of parse() method, it is used to return the string equivalent of the values stores on MimeHeader.
7. 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());
}
}
[A] html
[B] text
[C] html/text
[D] text/html

Answer: D. text/html

Explanation:

Host URL is written in html and simple text.
8. Which of these is an instance variable of class httpd?
[A] port
[B] cache
[C] log
[D] All of the mentioned

Answer: D. All of the mentioned

Explanation:

There are 5 instance variables : port, docRoot, log, cache and stopFlag. All of them are private.
9. Which of these is an instance variable of httpd that is a Hashtable?
[A] port
[B] cache
[C] log
[D] stopFlag

Answer: C. log

Explanation:

cache is the Hashtable where all of the files are cached in RAM and is initialized when the object is created.
10. 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.eduzip.com/javamcq");
System.out.print(obj.toExternalForm());
}
}
[A] eduzip
[B] eduzip.com
[C] www.eduzip.com
[D] http://www.eduzip.com/javamcq

Answer: D. http://www.eduzip.com/javamcq

Explanation:

toExternalForm() is used to know the full URL of an URL object.

Are these questions helpful for you?


Comments: (Your feedback is valuable to us)

yt 8 months ago Reply

Nice


kirupanandini 1 year ago Reply

good