JavaScript 6e – Test Review Questions
Chapter 9: Managing State Information and Security
True / 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.
 	
a. 	
True	

b. 	
False	

REFERENCES:  	
623	

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

b. 	
False	

REFERENCES:  	
625	

3. The Web Storage API is supported by all browsers in use on the web today.
 	
a. 	
True	

b. 	
False	

REFERENCES:  	
655	

4. A window, tab, or frame can view and modify the elements and properties of a document displayed in any other window, tab, or frame.
 	
a. 	
True	

b. 	
False	

REFERENCES:  	
659	

5. Cookies are stored on a user's computer as plain text files.
 	
a. 	
True	

b. 	
False	

REFERENCES:  	
635	

Multiple Choice	

6. HTTP was originally designed to be ____, which means that web browsers stored no persistent data about a visit to a website.
 	
a. 	
stateless	
b. 	
stateful	

c. 	
state-aware	
d. 	
state-active	

REFERENCES:  	
619	

7. You create hidden form fields with the ____ element.
 	
a. 	
option	
b. 	
select	

c. 	
input	
d. 	
hidden	

REFERENCES:  	
628	

8. You can use a(n) ____ to pass information, such as search criteria, from one web page to another.
 	
a. 	
text area	
b. 	
query string	

c. 	
label	
d. 	
image button	

REFERENCES:  	
623	

9. To create a query string, you add a ____ immediately after a URL, followed by the query string.
 	
a. 	
&	
b. 	
!	

c. 	
?	
d. 	
%	

REFERENCES:  	
623	

10. You separate individual name-value pairs within a query string using ____.
 	
a. 	
%	
b. 	
&	

c. 	
$	
d. 	
?	

REFERENCES:  	
623	

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

c. 	
parameters	
d. 	
search	

REFERENCES:  	
623	

12. The most widespread way on the web today of storing state information on a user's computer is using ____.
 	
a. 	
cookies	
b. 	
scripts	

c. 	
hidden form fields	
d. 	
query strings	

REFERENCES:  	
634	

13. ____ cookies remain available only for the current browser session.
 	
a. 	
Persistent	
b. 	
Temporary	

c. 	
Local	
d. 	
Global	

REFERENCES:  	
635	

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

c. 	
Local	
d. 	
Temporary	

REFERENCES:  	
635	

15. You use the ____ property of the Document object to create cookies in name-value pairs.
 	
a. 	
query	
b. 	
state	

c. 	
hidden	
d. 	
cookie	

REFERENCES:  	
635	

16. The cookie property is created with a required ____ attribute.
 	
a. 	
value	
b. 	
path	

c. 	
name	
d. 	
expires	

REFERENCES:  	
636	

17. You can use special characters in your cookies if you use ____.
 	
a. 	
encoding	
b. 	
Unicode	

c. 	
strings	
d. 	
URIs	

REFERENCES:  	
637	

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

c. 	
encodeURIComponent()	
d. 	
encodeComponent()	

REFERENCES:  	
637	

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

c. 	
secure	
d. 	
domain	

REFERENCES:  	
642	

20. The ____ attribute determines the availability of a cookie to other web pages on a server.
 	
a. 	
domain	
b. 	
secure	

c. 	
path	
d. 	
expires	

REFERENCES:  	
646	

21. The ____ attribute is used for sharing cookies across multiple servers in the same domain.
 	
a. 	
expires	
b. 	
domain	

c. 	
path	
d. 	
secure	

REFERENCES:  	
646, 647	

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

c. 	
path	
d. 	
secure	

REFERENCES:  	
648	

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

c. 	
Seal coding	
d. 	
Strong coding	

REFERENCES:  	
657	

24. The ____ property of the Document object changes the origin of a document to its root domain name.
 	
a. 	
root	
b. 	
domain	

c. 	
environment	
d. 	
path	

REFERENCES:  	
660	

25. To delete a cookie, you change the ____ property.
 	
a. 	
domain	
b. 	
expires	

c. 	
path	
d. 	
secure	

REFERENCES:  	
651	

Completion	

26. Information about individual visits to a website is called __________ information.
REFERENCES:  	
619	

27. To extract the contents of a query string except for the question mark, you use the __________ method.
REFERENCES:  	
625	

28. __________ is a newer specification than cookies for storing state information on a user's computer.
REFERENCES:  	
634, 635	

29. To use a cookie or other text string encoded with the encodeURIComponent() function, you must first decode it with the __________ function.
REFERENCES:  	
637	

30. __________ are small pieces of information about a user that are stored in text files on a user’s computer.
REFERENCES:  	
634	

	

Subjective Short Answer	

31. Describe the advantages and disadvantages of the original stateless design of the web.
REFERENCES:  	
619	

32. What are some of the reasons for maintaining state information?
REFERENCES:  	
619	

33. Describe how to extract all the contents of a query string except for the question mark.
REFERENCES:  	
625	

34. Describe how to convert the individual pieces of information in a query string into array elements. Include sample code.
REFERENCES:  	
626	

35. What limitations on the use of cookies are described in the cookie specification?
REFERENCES:  	
635	

36. What steps do you need to take to use special characters in your cookies?
REFERENCES:  	
637	

37. Provide one reason for using the Web Storage API today, and one reason not to use it.
REFERENCES:  	
655	

38. Why should you delete persistent cookies that your program does not need?
REFERENCES:  	
654	

39. Explain how to delete a cookie. Include sample code.
REFERENCES:  	
651, 652	

40. What are the security areas of most concern to JavaScript programmers?
REFERENCES:  	
658