Response Request Objects - Quiz Explanation

The correct answers are indicated below, along with the text that explains the correct answers.
 
1. When a browser first contacts a Web server, each computer identifies itself to the other and exchanges information about the file types, features, and languages each supports. That information is sent in which of the following objects?
Please select the best answer.
  A. A cookie.
  B. A querystring.
  C. An HTTP header.
  D. An HTML header.
  The correct answer is C.
A is incorrect because a cookie may only be sent after the Web servers have connected successfully. B is incorrect because the querystring, while part of a URL, is only processed after the connection is made. D is incorrect because the HTML header is not sent until the browser indicates it is ready to receive files from the server.


2. If you want to read user information appended to a URL, which of the Response object's methods do you use?
  A. Cookies.
  B. Query.
  C. Form.
  D. Server variables.
  The correct answer is B.
A is incorrect because cookies are written to a user's hard disk, not appended to URL's. C is incorrect because the Form object reads data from an HTML form; a querystring replaces form data entry. D is incorrect because server variables are kept on the server and not appended to a URL.

3. You want to create cookies with multiple values; you can do that by setting multiple instances of what element in the Request.Cookies statement?
  A. Name.
  B. Field.
  C. Index.
  D. Key.
  The correct answer is D.
A is incorrect because the Name property represents the cookie as a whole, not a part of it. B is incorrect because the term field refers to part of a table, not part of a cookie. C is incorrect because, while you can create an index from unique cookie values such as UserID's, there is no element of the Request.Cookies statement called an index.

4. When a user opens a particular page, you want to send that user to another page using the Response.Redirect method. What happens when you put a Response.Redirect statement above the opening HTML tag in an ASP document?
  A. An error occurs, indicating the header was already sent.
  B. An error occurs, indicating the header wasn't sent properly.
  C. An error occurs, indicating the server tried to send the header twice.
  D. The redirection occurs.
  The correct answer is D.
A, B, and C are incorrect because the Response.Redirect method is properly placed above the opening HTML tag and would not generate an error.

5. You need to set the Size attribute of a multi-valued cookie named Preferences on a user's computer.
Which of the following code snippets would you use for that?
  A. Response.Cookies("Preferences")("Size")="Large"
  B. Response.Cookies("Size")("Preferences")="Large"
  C. Response.Cookies("Preferences.Size")="Large"
  D. Response.Cookies("Preferences","Size")="Large"
  The correct answer is A.
B is incorrect because the key name must come after the cookie name in the Response.Cookies statement.
C is incorrect because the Size key, while it may be thought of as a property of the Preferences cookie, is not written using "dot" notation. D is incorrect for the same reason as C, though the incorrect character is a comma.

<%@ include file="../../responsive_horizontal.jsp" %>