Lab 4
Debugging Java Programs
Pre
Test
|
Name: |
Last four digits of SSN: |
|
Lab Section: |
|
1. Before using
the Integrated Debugger, you must instruct the compiler to generate information
that is not normally generated. True or false?
a. True
b. False
2. Which of the
following statements is true about syntax errors?
I.
Syntax errors are revealed at runtime.
II.
Syntax errors are similar to breaking English
grammar rules.
III.
Syntax errors are detected by the Java compiler.
IV.
An example of a syntax error is a missing ; at
the end of a Java statement.
3. Which of the
following errors will be caught at runtime?
I.
A missing } at the end of a method.
II.
Divide by 0.
III.
File Not Found.
IV.
Infinite
4. Which type of
error will cause your program to crash?
a. Runtime
b. Synatx
c. Neither
d. Both
5. What
is a debugger?
a. A program that allows you to type in a program and make changes to it.
b. A
program that helps you find syntax errors in a program.
c. A
program that helps you document your program.
d. A
program that helps you find runtime errors in a program.
Answer: d
6.
Which of the following statements are
true?
I.
To speed up the debugging process you
should make multiple changes when you are trying to track down a bug.
II.
You should not trust your intuitions
when you debug your code.
III.
Debugging depends on an objective and
reasoned approach.
IV.
The clue to what is wrong in your code
is in the values of your variables.
7.
What is a debugger breakpoint?
a. A
way to stop program execution and exit the debugger.
b. A
way to single step through program code.
c. A
way to interrupt program execution at a certain point in the code.
d. A
way to split a line of source code so it is more readable.
Answer:
c
8.
The compiler always indicates the exact line where
a syntax error is present. True or false?
a. True
b. False
Answer: b
Comprehension
9. The process listed below includes a step that should not be performed when debugging a Java program using the Integrated Debugger. Which step of the process listed below should not be performed?
a. Have an idea of where the program is not working.
b. Set a breakpoint prior to the line of code you think is not working.
c. Ensure the variable values are correct when you reach the breakpoint.
d. Change any incorrect variable values.
e. Step through the program, watching for the error to occur.
Answer: d
10. Consider the following code:
int count = 1;
while (count < 10){
System.out.println (hi);
count++
}
Which type of error is present?
Answer: b