Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Module 0 2 Lab Assignment - Bug Hunt! 1 . Open SampleProgram.Java in your IDE. This file has been provided to you. 2 . Preview
Module Lab Assignment Bug Hunt!
Open SampleProgram.Java in your IDE. This file has been provided to you.
Preview the programming in your debugging perspective.
With a Word document open, take a screen shot use the snipping tool of your open IDE then paste it into the Word document. Label it Java IDE Open. It should look similar to the one above but not exact. Name your Word file Module
Switch back to your regular view.
To change the perspective windows:
View the upperright corner of the Eclipse window and click on the icon:
To the left of that icon is another unlabeled icon that looks like: This is the perspectives icon so click it to open the debug perspective.
Now you should see and Icon named Debug
Reverse this process to get back to the main window.
Working with Suspending, Resuming and Terminating a Program
With the SampleProgram open, select Debug as and then select Java application. You should see that sample program is printing output to the Console window.
Switch to the Debug perspective, and then find the window labeled Debug in the upper left of Eclipse.
In the Debug window at the top is a toolbar of icons that includes three that we'll use: These icons are the Resume, Suspend and Terminate buttons from left to right
Try the Suspend button looks like a pause button and notice its effect on the program. Take a screen shot and add it to the Word document.
Now press the Resume button a yellow bar and a green arrow and see how it effects the program.
Try suspending and resuming a few times.
Finally, press the Terminate button red square to end the program.
This is how you use the programs general controls over the debugger.
In the Debug perspective, look over to the left and you will notice the grayish vertical bar at the far left of that window. To set a break point, you simply double click this bar at the line where you want to stop the program.
Set a break point at the System.out.println
Note: You will see a bulling point appearing at the bar indicating that you've set a breakpoint at this line of code circled in red below:
Take a screen shot and add it to your Word document calling it break point.
Run the program in debug mode again Run Debug As Java Application and you'll see that the program stops at the breakpoint.
Note: the line will be highlighted in green and the icon in the bar changes to show that you've suspended at that breakpoint circled in red below:
Insert another breakpoint at the method call to innerLoop method
Insert another breakpoint at the final call to System.out.println
Take a screen shot and add it to the Word file with a paragraph describing what you think it is doing.
Find the Breakpoints window in the upper right of the Eclipse window, it looks like the screen shot below. Be aware you may have to click on the Breakpoints tab in order to display.
The three breakpoints you have set should display in this window and it will provide you with information about each. It can include line number, class name, method name, etc. and it is designed for you to be able to double click on the entry and it will take you to that line within your code. For small amounts of code, you may not need this but for larger amounts, it may be easier for you to utilize this feature then to scroll through the lines to find it
To disable breakpoints, you simply uncheck them in the Breakpoints window or by rightclicking on its listing in the Breakpoints window and the selecting Disable.
Disable the innerloop, and then Resume execution of your program and notice the effect.
Take a screen shot and add it to the Word document.
Stepping Control
Once we've stopped at a breakpoint, often you'll want to be able to control the execution of the subsequent lines of code. The debugger has buttons that provide us "Step Into" "Step Over" and "Step Return" control that look like: They are located in the tool bar at the top of the debug window to the right of the buttons we used to resume and suspend execution.
Try working with all three. Take a screen shot of onethen add to the Word document with an explain the differences in what you are seeing from one to the other.
Evaluating Expressions
Conditional expressions can allow you to view how expressions can change.
Open the Expressions window by selecting the menu Window Show View and select Expressions.
Now highlight and copy ctrlC in the source code displayed in the editor window the expression j in the for loop of the innerLoop method.
Right click on the Expressions window and click on Add Watch Expression.
Paste ctrlV the copied expression into the text area of the popup window that appears and click Ok
Step through your program until your expression widow matches what is shown below.
Take a screen shot an
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started