Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

package week_2; /** * * * Add a breakpoint to the start of one of your programs.

ID: 3881789 • Letter: P

Question

 package week_2;  /**  *  *  * Add a breakpoint to the start of one of your programs. Debug it, and then use the debugger to step through your program, and inspect the value of the variables.   How do you add a breakpoint? How can you remove a breakpoint?   Can you add more than one breakpoint?   How do you activate and deactivate breakpoints?   How do you move through your code one line at a time?   How do you see the value of a variable?   What does clicking on the triangle next to a variable on the variables pane do? (Such as the arrow next to names in the screenshot below)   */ public class Question_3_Debugger {      // TODO In the methods that follow, make sure you can do the debugging tasks.     // TODO Write a comment answering the question     // TODO Change the 'return false' statements to 'return true' as you use the debugger's tools.     // To practice, you can try examining this program in the debugging.      public static void main(String[] args) {          // Some test variables and method calls to examine in the debugger.         int number = 5;         number = number + 2;         String text = "Hello World";          double result = halfThisNumber(number);         System.out.println(result);     }      public static double halfThisNumber(int number) {         // TODO in the debugger, watch the new variable bein 
      }  
 g created         double half = number / 2.0;         return half;      public boolean canAddAndRemoveBreakPoint() {          // TODO how do you add a breakpoint?         // TODO how do you remove a breakpoint?          return false;      }       public boolean canStartDebugger() {          // TODO How do you start the debugger?          return false;     }       public boolean canAddManyBreakpoints() {          // TODO     Can you add more than one breakpoint?          return false;     }       public boolean canStepThroughCode() {         // TODO     How do you move through your code one line at a time?          return false;     }      public boolean canSeeValueOfVariables() {         // TODO     How do you see the value of a variable?          return false;     }      public boolean canSeeValuesOfVariablesInStructures() {          // TODO   What does clicking on the triangle next to a variable on the variables pane do?          return false;     }   } 

Explanation / Answer

The question is not clear. I hope that you wanted to know about how debugging a program is to be done. Here iam explaining the debug process using the Java Eclipse Editor.

Debugging is the process running a program interactively while watching the source code and variables during the execution.

During debugging, breakpoint is a place in the source code that specifies where the execution of the program should stop during the debug process. Once the program is stopped the values of the variables can be investivated or changed etc.

Q ) How do you add a breakpoint? How can you remove a breakpoint?

A ) To add a breakpoint in your source code, right click in the left margin in the java editor and select Toggle Breakpoint. Alternatively we can double click on this position.

To remove a already created breakpoint in your source code, right click in the left margin in the java editor and select disable breakpoint. Alternatively we can double click on the selected break point.


Q) Can you add more than one breakpoint?

Yes we can add more than one breakpoint. The process is same for adding all the break points one by one.

Q)How do you activate and deactivate breakpoints?

In the Window menu-> ShowView sub menu select Breakpoints. This will display all the breakpoints created. To activate the breakpoint select the(get the tick mark) on the existing break point.

In the Window menu-> ShowView sub menu select Breakpoints. This will display all the breakpoints created. To activate the breakpoint deselect the existing break point(remove the tick mark).


Q) How do you move through your code one line at a time?

Run the program in debug mode. Click F6 button to debug the code line by line. Keep on pressing the F6 button to debug the code line by line until the program is completed.


Q) How do you see the value of a variable?

In the Window menu-> ShowView sub menu select Variables. This will open the variable menu and display the value of all the variables present at the breakpoint.
To see the value of one variable, select the variable and click CTRL+SHIFT+I

Q) What does clicking on the triangle next to a variable on the variables pane do? (Such as the arrow next to names in the screenshot below)

It allows to change the value of the variable temporarily for that execution to some other value at that point.