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? Answer: a 2. Which of these class is used to create servers that listen for either local or remote client programs? Answer: b 3. Which of these is a standard for communicating multimedia content over email? Answer: c 4. Which of these methods is used to make raw MIME formatted string? Answer: a 5. Which of these class is used for operating on request from the client to the server? Answer: d 6. Which of these method of MimeHeader is used to return the string equivalent of the values stores on MimeHeader? Answer: b 7. What will be the output of the following Java program? Note: Host URL is written in html and simple text. 8. Which of these is an instance variable of class httpd? Answer: d 9. What will be the output of the following Java program? a)
a) LogMessage
b) LogResponse
c) Httpdserver
d) httpdResponse
Clarification: LogMessage is a simple interface that is used to abstract the output of messages from the httpd.
a) httpServer
b) ServerSockets
c) MimeHeader
d) HttpResponse
Clarification: None.
a) http
b) https
c) Mime
d) httpd
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.
a) parse()
b) toString()
c) getString()
d) parseString()
Clarification: None.
a) http
b) httpDecoder
c) httpConnection
d) httpd
Clarification: None.
a) string()
b) toString()
c) convertString()
d) getString()
Clarification: toString() does the reverse of parse() method, it is used to return the string equivalent of the values stores on MimeHeader.
import java.net.*;
class networking
{
public static void main(String[] args) throws Exception
{
URL obj = new URL("javamcq");
URLConnection obj1 = obj.openConnection();
System.out.print(obj1.getContentType());
}
}
a) html
b) text
c) html/text
d) text/html
Clarification: None.
Output:
$ javac networking.java
$ java networking
text/html
a) port
b) cache
c) log
d) All of the mentioned
Clarification: There are 5 instance variables: port, docRoot, log, cache and stopFlag. All of them are private.
import java.net.*;
class networking
{
public static void main(String[] args) throws MalformedURLException
{
URL obj = new URL("javamcq");
System.out.print(obj.toExternalForm());
}
}
b) .com
c) www..com
d) javamcq
Clarification: toExternalForm() is used to know the full URL of an URL object.
Output:
$ javac networking.java
$ java networking
https://www..com/javamcq
