Name: 
 

Practice Test on State Information and Security



True/False
Indicate whether the statement is true or false.
 

 1. 

One way to preserve information following a user’s visit to a Web page is to append a query string to the end of a URL.
 

 2. 

For a Web page to use the information in a query string, your JavaScript program must first parse the string.
 

 3. 

Query strings permanently maintain state information.
 

 4. 

Hidden form fields maintain state information between Web pages, and the data they contain are kept once the Web page that reads the hidden fields closes.
 

 5. 

The Web was originally designed to be read-only.
 

Multiple Choice
Identify the choice that best completes the statement or answers the question.
 

 6. 

HTTP was originally designed to be ____, which means that Web browsers stored no persistent data about a visit to a Web site.
a.
stateless
c.
state-aware
b.
statefull
d.
state-active
 

 7. 

You create hidden form fields with the ____ element.
a.
<state>
c.
<input>
b.
<information>
d.
<hidden>
 

 8. 

The only attributes that you can include with a hidden form field are the name and ____ attributes.
a.
expires
c.
secure
b.
path
d.
value
 

 9. 

You can use a(n) ____ to pass information, such as search criteria, from one Web page to another.
a.
text area
c.
label
b.
query string
d.
image button
 

 10. 

To pass data from one Web page to another using a query string, add a(n) ____ immediately after a URL, followed by the query string (in name=value pairs) for the information you want to preserve.
a.
&
c.
?
b.
!
d.
%
 

 11. 

You separate individual name=value pairs within the query string using ____.
a.
%
c.
$
b.
&
d.
?
 

 12. 

The ____ property of the Location object contains a URL’s query or search parameters.
a.
query
c.
parameters
b.
arguments
d.
search
 

 13. 

To make it possible to store state information beyond the current Web page session, Netscape created ____.
a.
cookies
c.
hidden form fields
b.
scripts
d.
query strings
 

 14. 

____ cookies remain available only for the current browser session.
a.
Persistent
c.
Local
b.
Temporary
d.
Global
 

 15. 

____ cookies remain available beyond the current browser session and are stored in a text file on a client computer.
a.
Persistent
c.
Local
b.
Global
d.
Temporary
 

 16. 

You use the ____ property of the Document object to create cookies in name=value pairs.
a.
query
c.
hidden
b.
state
d.
cookie
 

 17. 

The cookie property is created with a required ____ attribute and four optional attributes: expires, path, domain, and secure.
a.
value
c.
name
b.
string
d.
size
 

 18. 

You can use special characters in your cookies if you use ____.
a.
encoding
c.
strings
b.
Unicode
d.
URIs
 

 19. 

The built-in ____ function is used in JavaScript for encoding the individual parts of a URI.
a.
encodeCookie()
c.
encodeURIComponent()
b.
encodeURLComponent()
d.
encodeComponent()
 

 20. 

When you read a cookie or other text string encoded with the encodeURIComponent() function, you must first decode it with the ____ function.
a.
parseURI()
c.
decodeURLComponent ()
b.
parseCookie()
d.
decodeURIComponent ()
 

 21. 

The ____ attribute of the cookie property determines how long a cookie can remain on a client system before it is deleted.
a.
path
c.
secure
b.
expires
d.
domain
 

 22. 

The ____ attribute determines the availability of a cookie to other Web pages on a server.
a.
domain
c.
path
b.
secure
d.
expires
 

 23. 

The ____ attribute is used for sharing cookies across multiple servers in the same domain.
a.
expires
c.
path
b.
domain
d.
secure
 

 24. 

The ____ attribute indicates that a cookie can only be transmitted across a secure Internet connection using HTTPS or another security protocol.
a.
domain
c.
path
b.
expires
d.
secure
 

 25. 

____ refers to the writing of code in such a way that minimizes any intentional or accidental security issues.
a.
Secure coding
c.
Seal coding
b.
Bulletproofing
d.
Strong coding
 

 26. 

The ____ property of the Document object changes the origin of a document to its root domain name.
a.
root
c.
environment
b.
domain
d.
path
 

Completion
Complete each statement.
 

 27. 

Information about individual visits to a Web site is called ____________________.
 

 

 28. 

A special type of form element, called a(n) ____________________, is not displayed by the Web browser and therefore allows you to hide information from users.
 

 

 29. 

A(n) ____________________ is a set of name=value pairs appended to a target URL.
 

 

 30. 

The passed query string is assigned to the ____________________ property of the target Web page Location object.
 

 

 31. 

____________________ are small pieces of information about a user that are stored by a Web server in text files on the user’s computer.
 

 

Matching
 
 
Match each item with a statement below:
a.
hidden form field
f.
toUTCString()
b.
query string
g.
path attribute
c.
cookies
h.
SSL
d.
name attribute
i.
secure coding
e.
encodeURIComponent()
 

 32. 

Also known as defensive coding
 

 33. 

Converts the Date object to a string, formatting it in Coordinated Universal Time
 

 34. 

Temporarily stores data that needs to be sent to a server along with the rest of a form, but that a user does not need to see
 

 35. 

Encrypts data and transfers it across a secure connection
 

 36. 

The only required parameter of the cookie property
 

 37. 

Allows cookies to be shared across a server
 

 38. 

Consists of a single text string containing one or more pieces of information
 

 39. 

Converts special characters in the individual parts of a URI to their corresponding hexadecimal ASCII value, preceded by a percent sign
 

 40. 

Originally created for use with CGI scripts, but are now commonly used by JavaScript and other scripting languages
 

Short Answer
 

 41. 

Describe the advantages and disadvantages of the original stateless design of the Web.
 

 42. 

What are some of the reasons for maintaining state information?
 

 43. 

How can you remove the question mark at the start of the query string?
 

 44. 

How can you convert the individual pieces of information in a query string into array elements?
 

 45. 

What are some of the limitations on the use of cookies that are enforced by Web browsers?
 

 46. 

How can you use special characters in your cookies?
 

 47. 

Why should you manually encode and decode cookies?
 

 48. 

Why should you delete persistent cookies that your program does not need?
 

 49. 

What are the steps to parse a cookie?
 

 50. 

What are the security areas of most concern to JavaScript programmers?
 



 
Check Your Work     Start Over