659). Which of these is a wrapper around everything associated with a reply from an http server?
[A]HTTP
[B]HttpResponse
[C]HttpRequest
[D]httpserver
Show Answer
Correct Answer: HttpResponse
Notes:
Answer: b
Explanation: HttpResponse is wrapper around everything associated with a reply from an http server.
660). Which of these transfer protocol must be used so that URL can be accessed by URLConnection class object?
[A]http
[B]https
[C]Any Protocol can be used
[D]None of the mentioned
Show Answer
Correct Answer: http
Notes:
Answer: a
Explanation: For a URL to be accessed from remote location http protocol must be used.
661). Which of these methods is used to know when was the URL last modified?
[A] LastModified()
[B]getLastModified()
[C]GetLastModified()
[D]getlastModified()()
Show Answer
Correct Answer: getLastModified()
Notes:
Answer: b
Explanation: None.
662). Which of these methods is used to know the type of content used in the URL?
[A]ContentType()
[B]contentType()
[C] getContentType()
[D] GetContentType()
Show Answer
Correct Answer: getContentType()
Notes:
Answer: c
Explanation: None.
663). Which of these data member of HttpResponse class is used to store the response from an http server?
[A]status
[B]address
[C]statusResponse
[D]statusCode
Show Answer
Correct Answer: statusCode
Notes:
Answer: d
Explanation: When we send a request to an http server it responds with a status code this status code is stored in statusCode and a textual equivalent which is stored in reasonPhrase.
664). What will be the output of the following Java program?
import java.net.*;
class networking
{
public static void main(String[] args) throws Exception
{
URL obj = new URL("https://www.sanfoundry.com/javamcq");
URLConnection obj1 = obj.openConnection();
System.out.print(obj1.getContentType());
}
}
[A]html
[B]text
[C] html/text
[D]text/html
Show Answer
Correct Answer: text/html
Notes:
Answer: d
Explanation: None.
Output:
$ javac networking.java
$ java networking
text/html
665). What will be the output of the following Java program?
import java.net.*;
class networking
{
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();
System.out.print(len);
}
}
[A]126
[B]127
[C]Compilation Error
[D]Runtime Error
Show Answer
Correct Answer: 127
Notes:
Answer: b
Explanation: None.
Output:
$ javac networking.java
$ java networking
127
666). What will be the output of the following Java program?
import java.net.*;
class networking
{
public static void main(String[] args) throws Exception
{
URL obj = new URL("https://www.sanfoundry.com/javamcq");
URLConnection obj1 = obj.openConnection();
System.out.print(obj1.getLastModified);
}
}
[A]june
[B]18-6-2013
[C]Tue 18 Jun 2013
[D]Tue Jun 18 2013
Show Answer
Correct Answer: Tue Jun 18 2013
Notes:
Answer: d
Explanation: None.
Output:
$ javac networking.java
$ java networking
Tue Jun 18 2013