Answered step by step
Verified Expert Solution
Link Copied!

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 02 Lab Assignment - Bug Hunt!
1. Open SampleProgram.Java in your IDE. This file has been provided to you.
2. Preview the programming in your debugging perspective.
3. 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 2.
4. Switch back to your regular view.
To change the perspective windows:
View the upper-right 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
5. 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.
6. 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).
7. 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.
8. Now press the Resume button (a yellow bar and a green arrow) and see how it effects the program.
9. Try suspending and resuming a few times.
10. 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.
11. 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):
12. Take a screen shot and add it to your Word document calling it break point.
13. 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):
14. Insert another breakpoint at the method call to innerLoop() method
15. Insert another breakpoint at the final call to System.out.println()
16. 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 right-clicking on its listing in the Breakpoints window and the selecting Disable.
17. Disable the innerloop, and then Resume execution of your program and notice the effect.
18. 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.
19. 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.
20. Open the Expressions window by selecting the menu Window -> Show View and select Expressions.
21. Now highlight and copy (ctrl-C) in the source code displayed in the editor window the expression j <10000 in the for loop of the innerLoop method.
22. Right click on the Expressions window and click on Add Watch Expression.
23. Paste (ctrl-V) the copied expression into the text area of the pop-up window that appears and click Ok.
24. Step through your program until your expression widow matches what is shown below.
25. Take a screen shot an

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions