Lab 4 – Debugging Java Programs

Pre Test

 

Name:

Last four digits of SSN:

Lab Section:

 

 

Knowledge/Memory

 

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

 

Answer: a

 

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.

 

  1. I, II & III
  2. II, III & IV
  3. III & IV
  4. I, II, III & IV

 

Answer:  b

 

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 Loop.

 

  1. I & II
  2. I, II & III
  3. II & III
  4. III & IV

 

Answer: c

 

4.      Which type of error will cause your program to “crash”?

 

a.       Runtime

b.      Synatx

c.       Neither

d.      Both

 

Answer: a

 

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.

  1. I & II
  2. II & III
  3. I & IV
  4. III & IV

 

Answer: d

 

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?

  1. Semantic
  2. Syntax
  3. Both
  4. Neither

 

Answer: b