Lab 4
- Debugging Java Programs
Post
Test
|
Name: |
|
|
|
|
1. Which of the
following statements are true about runtime errors?
I.
Runtime errors are revealed when the program is
executing.
II.
An example of a runtime error is a missing ‘;’ at
the end of a Java statement.
III.
An example of a runtime error is a divide by zero.
IV.
Print statements are a useful approach to finding a
runtime error.
Answer: a
2. The Step
and Step Into functions in the debugger behave identically if the
current line does not contain a method call.
a. True
b. False
Answer: a
3. The three
major types of programming errors are:
a. Semantic,
Syntax, Logic
b. Compiler,
Runtime, Execution
c. Syntax,
Semantic, Runtime
d. Logic,
Grammar, Typo
4. The
clue to what is wrong in your code is in the values of your variables.
a. True
b. False
5. Which of the following errors are examples of semantic errors?
I. An infinite loop.
II. An algorithm improperly translated into code.
III. Improper program flow of control.
IV. An undeclared identifier.
a. I, II & IV
b. II & III
c. I, II & III
d. I & IV
Comprehension:
6. The advantages of using a debugger over
print statements include:
I.
The
debugger allows the programmer to modify code and recompile it from within the
debugger.
II.
The debugger gives the programmer more control over what is going on
during execution.
III.
Debuggers are interactive tools.
IV.
The debugger shows the exact location of the error.
a. I, II &
III
b. II & III
c. I, II & IV
d. I, II, III & IV
Answer: b
7. Coding practices such as the use of white
space, indentation, meaningful variable names, etc. do not generally help the
program debugging process. True or false?
a. True
b. False
8. Which of the following techniques is not
an acceptable debugging technique?
a. Looking at the code.
b. Using print statements.
c. Using a debugger.
d. All of the above are acceptable
debugging techniques.
Answer: d
9. Which of the following statements are true about using print statements to debug code?
I. The information printed by a print statement can be changed at runtime.
II. Print statements can identify sections of code that are not executed.
III. Using print statements to debug code is preferred to using a debugger because debuggers are too complex and cannot be used on very large programs.
IV. Using print statements to debug code generally requires recompilation when the debugging strategy changes.
a. I & II
b. II & IV
c. I, II & IV
d. III & IV
Answer: b
10. Before setting a breakpoint, you should:
Answer: c