250+ TOP MCQs on Scripted HTTP and Answers

Javascript Multiple Choice Questions on “Scripted HTTP”.

1. Which property helps to initiate the HTTP requests?
a) request
b) location
c) send
d) write

Answer: b
Clarification: It is possible for JavaScript code to script HTTP, however. HTTP requests are initiated when a script sets the location property of a window object or calls the submit() method of a form object. The location object is part of the window object and is accessed through the window.location property.

2. Which method is an alternative of the property location of a window object?
a) submit()
b) locate()
c) load()
d) write()

Answer: a
Clarification: HTTP requests are initiated when a script sets the location property of a window object or calls the submit() method of a form object. In both cases, the browser loads a new page.

3. Which of the following uses scripted HTTP?
a) XML
b) HTML
c) Ajax
d) CSS

Answer: c
Clarification: AJAX stands for Asynchronous JavaScript And XML. The key feature of an Ajax application is that it uses scripted HTTP to initiate data exchange with a web server without causing pages to reload.

4. Which of the below is a liberal reverse of Ajax?
a) HTTP
b) HTML
c) XML
d) Comet

Answer: d
Clarification: Comet is the reverse of Ajax: in Comet, it is the web server that initiates the communication, asynchronously sending messages to the client. The big advantage of Comet is that each client always has a communication link open to the server.

5. The other name for Comet is _____________
a) Server Push
b) Ajax Push
c) HTTP Streaming
d) All of the mentioned

Answer: d
Clarification: Comet is a web application model where a request is sent to the server and kept alive for a long time, until a time-out or a server event occurs. Other names for Comet include “Server Push”, “Ajax Push”, “HTTP Streaming”.

6. Which is the element that has a src property to initiate HTTP GET request?
a) img
b) iframe
c) script
d) both img and script

Answer: d
Clarification: Both img and script contains the src property that can be set to initiate an HTTP GET request. The src property sets or returns the value of the src attribute of an image.The required src attribute specifies the URL of an image.

7. XMLHttpRequest is a ____________
a) Object
b) Class
c) Both Object and Class
d) Array

Answer: c
Clarification: XMLHttpRequest is both an object and a class. The XMLHttpRequest object can be used to request data from a web server.

8. Which of the following are the features of an HTTP request?
a) URL being requested
b) Optional request body
c) Optional set of request headers
d) All of the mentioned

Answer: d
Clarification: An HTTP request consists of four parts :

  1. the HTTP request method or “verb”
  2. the URL being requested
  3. an optional set of request headers, which may include authentication information
  4. an optional request body

9. Which of the following is a feature of the HTTP response?
a) Mandatory response body
b) Optional response body
c) URL being released
d) Optional set of response headers

Answer: a
Clarification: The HTTP response sent by a server has three parts :

  1. a numeric and textual status code that indicates the success or failure of the request
  2. a set of response headers
  3. the response body

10. Which is the appropriate code to begin a HTTP GET request?
a) request.open(“GET”,”data”);
b) request.open(GET,”data.csv”);
c) request.open(“GET”,”data.csv”);
d) request.open(“GET”);

Answer: c
Clarification: The code that begins a HTTP GET request for the contents of the specified URL is

request.open("GET","data.csv");

To send a request to a server open() and send() methods of the XMLHttpRequest object are used.

Leave a Reply

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