JavaScript 6e – Test Review Questions
Chapter 4: Debugging and Error Handling
True / False	

1. Each time a program calls a procedure, the procedure is added to the top of the call stack, and then removed after it finishes executing.
 	
a. 	
True	

b. 	
False	

REFERENCES:  	
259	

2. Syntax refers to the order in which various parts of a program run, or execute.​
 	
a. 	
True	

b. 	
False	

REFERENCES:  	
213	

3. For each error encountered, a browser's console displays a line number ​and a description of the error.
 	
a. 	
True	

b. 	
False	

REFERENCES:  	
218	

4. You log values to the console using the window.alert() method.​
 	
a. 	
True	

b. 	
False	

REFERENCES:  	
231	

5. ​A breakpoint is a designation added to a specific statement in a program that causes program execution to pause when it reaches that statement.
 	
a. 	
True	

b. 	
False	

REFERENCES:  	
245
246	

Multiple Choice	

6. A ____ error occurs when the interpreter fails to recognize code.
 	
a. 	
logic	
b. 	
syntax	

c. 	
web	
d. 	
run-time	

REFERENCES:  	
213	

7. A ____ error occurs when the JavaScript interpreter encounters a problem while a program is executing.
 	
a. 	
run-time	
b. 	
syntax	

c. 	
logic	
d. 	
browser	

REFERENCES:  	
214	

8. A ____ error is a flaw in a program’s design that prevents the program from running as you anticipate.
 	
a. 	
compile-time	
b. 	
syntax	

c. 	
logic	
d. 	
run-time	

REFERENCES:  	
215	

9. When using the console.log() method to trace bugs, it can be helpful to use a ____ program.
 	
a. 	
script	
b. 	
hub	

c. 	
tracing	
d. 	
driver	

REFERENCES:  	
232	

10. The ____ is the ordered list maintained by a JavaScript processor containing all the procedures that have been called but have not yet finished processing.
 	
a. 	
call queue	
b. 	
call heap	

c. 	
call stack	
d. 	
methods list	

REFERENCES:  	
259	

11. ____ allows programs to handle errors as they occur in the execution of a program.
 	
a. 	
Error coding	
b. 	
Form validation	

c. 	
Input validation	
d. 	
Exception handling	

REFERENCES:  	
263	

12. You enclose code that may contain an exception in a ____ statement.
 	
a. 	
throw	
b. 	
catch	

c. 	
throws	
d. 	
try	

REFERENCES:  	
263	

13. You use a ____ statement within a try block to specify an error message.
 	
a. 	
catch	
b. 	
call	

c. 	
throw	
d. 	
throws	

REFERENCES:  	
264	

14. After you throw an error, you use a ____ statement to handle the error.
 	
a. 	
try	
b. 	
catch	

c. 	
handle	
d. 	
capture	

REFERENCES:  	
264	

15. ​The rules of a programming language are known as its ____.
 	
a. 	
​logic	
b. 	
​syntax	

c. 	
​call stack	
d. 	
​console	

REFERENCES:  	
213	

16. ​A program's ____ is the order in which various parts of the program run, or execute.
 	
a. 	
​logic	
b. 	
​syntax	

c. 	
​call stack	
d. 	
​console	

REFERENCES:  	
213	

17. The console.log() debugging method ​results in messages ____.
 	
a. 	
​written to the text of the document being debugged	
b. 	
​displayed in dialog boxes	

c. 	
​displayed in the browser console	
d. 	
​available only to the JavaScript processor	

REFERENCES:  	
231	

18. The window.alert() debugging method ​results in messages ____.
 	
a. 	
​written to the text of the document being debugged	
b. 	
​displayed in dialog boxes	

c. 	
​displayed in the browser console	
d. 	
​available only to the JavaScript processor	

REFERENCES:  	
225	

19. The debugging tools built into modern browsers are especially useful in tracking down​ ____.
 	
a. 	
​compile-time errors	
b. 	
​syntax errors	

c. 	
​run-time errors	
d. 	
​logic errors	

REFERENCES:  	
242	

20. ____ is the temporary suspension of program execution so you can monitor values and trace program execution.​
 	
a. 	
​The call stack	
b. 	
​Break mode	

c. 	
​Debugging	
d. 	
​Tracing	

REFERENCES:  	
245	

21. After you evaluate code for exceptions, you can use a ____ statement to perform cleanup or necessary tasks.​
 	
a. 	
​try	
b. 	
​throw	

c. 	
​catch	
d. 	
​finally	

REFERENCES:  	
265	

22. Which of the following JavaScript statements works like a breakpoint?​
 	
a. 	
​break;	
b. 	
​"use strict";	

c. 	
​debugger;	
d. 	
​console.log();	

REFERENCES:  	
276	

23. Which of the following JavaScript statements requests that processors remove some features from the language and require more stringent syntax for other features?​
 	
a. 	
​break;	
b. 	
​"use strict";	

c. 	
​debugger;	
d. 	
​console.log();	

REFERENCES:  	
276	

24. An infinite loop is an example of a(n) ____ error.​
 	
a. 	
​syntax	
b. 	
​run-time	

c. 	
​logic	
d. 	
​user	

REFERENCES:  	
215	

25. Writing values directly to the console is known as ____.​
 	
a. 	
​logging	
b. 	
​writing	

c. 	
​stepping out	
d. 	
​breaking	

REFERENCES:  	
231	

Completion	

26. ____________________ is the examination of individual statements in an executing program.
REFERENCES:  	
225	

27. The term ____________________ refers to the temporary suspension of program execution so that you can monitor values and trace program execution.
REFERENCES:  	
245	

28. You implement custom error handling using the ____________________ event.​
REFERENCES:  	
270	

29. In ____________________ mode, some features are removed from the language, while other features require more stringent syntax.​
REFERENCES:  	
276	

30. ____________________ is the process of tracing and resolving errors in a program.​
REFERENCES:  	
212	

Subjective Short Answer	

31. What is the difference between syntax errors and run-time errors?
REFERENCES:  	
214	

32. Briefly explain how to use comments to locate bugs with JavaScript.
REFERENCES:  	
236, 237	

33. Explain the three stepping options found in the debugging tools in modern browsers.​
REFERENCES:  	
251	

34. Explain how access to the call stack is useful in debugging. ​
REFERENCES:  	
259, 260	

35. Describe two advantages of implementing custom error handling.​
REFERENCES:  	
270	

36. Name two tools you can use to analyze your HTML code for errors, and describe how to use them for this task.​
REFERENCES:  	
272	

37. Explain how strict mode can be useful in debugging.​
REFERENCES:  	
276	

38. What is a dependency and what role do dependencies play in debugging?​
REFERENCES:  	
241	

39. How is setting breakpoints useful in debugging?​
REFERENCES:  	
246, 247	

40. What is the difference between a variables list and a watch list in browser debugging tools?​
REFERENCES:  	
253