Question
Please help me write out this code in java, the following URL's that I have attached are needed : http://www.csd.uwo.ca/courses/CS1027a/code/ExceptionExample1.java http://www.csd.uwo.ca/courses/CS1027a/code/ExceptionExample2.java http://www.csd.uwo.ca/courses/CS1027a/code/ExceptionExample6.java http://www.csd.uwo.ca/courses/CS1027a/code/ExceptionExample7.java http://www.csd.uwo.ca/courses/CS1027a/code/ExceptionExample8.java http://www.csd.uwo.ca/courses/CS1027a/code/ExceptionExample9.java
Please help me write out this code in java, the following URL's that I have attached are needed :
http://www.csd.uwo.ca/courses/CS1027a/code/ExceptionExample1.java
http://www.csd.uwo.ca/courses/CS1027a/code/ExceptionExample2.java
http://www.csd.uwo.ca/courses/CS1027a/code/ExceptionExample6.java
http://www.csd.uwo.ca/courses/CS1027a/code/ExceptionExample7.java
http://www.csd.uwo.ca/courses/CS1027a/code/ExceptionExample8.java
http://www.csd.uwo.ca/courses/CS1027a/code/ExceptionExample9.java
http://www.csd.uwo.ca/courses/CS1027a/code/ExceptionExample10.java
http://www.csd.uwo.ca/courses/CS1027a/code/ExceptionExample11.java
http://www.csd.uwo.ca/courses/CS1027a/code/ExceptionExample12.java
Exercise 1: Experimenting with Exceptions in this exercise, you will experiment with some examples of code that generates exceptions and answer some questions on the examples. Download the Exception Examples 1,2,6,7,8.9, 101, and 12 from the Sample ode section of the course webpage. It may be simplest if you put them all in one project, and run them separately as you progress through this Exercise. Note that some of them will (purposely) not compile. . Run examples 1 and 2. They both have an "unchecked exception": one that you do not explicitly need to check for in the code, but will be generated if the conditions for the exception occur o What is the condition that generates the exception in each of these programs? o Which of the two examples allows the program to continue even if the exception is generated? . Run examples 6 and 7. They both have the same exception, but notice that the try-catch statement is in a different method in each of the examples. This is an example of propagating the exception, as mentioned in the exception lecture notes. (Notice also that these examples show how print statements can be included to allow us to see where we are in the execution of the program, when the variable debug has the value true.) o What is the statement that actually generates the exception in example 6? In example 7? o In example 7, does execution of the method change continue after the statement that generated the exception? o What happens of you change the statement containing debugtrue to debug false? . Now run example 8. Notice that both the main method and the method change have a try-catch statement. In which method(s) is the exception actually caught in this case? . Run example 12. This is an example that contains multiple possible exceptions. Try running it for an illegal input such as the letter A, and then for a legal integer input such as the value 6. When handling arn exception, how many of each of the following clauses can be present in a try/catch statement? o number of try clauses possible? o number of catch clauses possible? Try to run example 9. Note that it does not compile. This is an example of an exception that is known as a 'checked" exception, and the method header must state that it is throwing an exception. Now run examples 10 and 11 using illegal input such as abc. What is the "checked" exception that is generated in examples 9, 10 and 11? . Add a loop to example 11, that asks the user for another input for as long as the input is not valid. You will need to use a while loop and a boolean variable that tells the program whether a valid input has yet been entered Exercise 2 clipse comes with a debugger which allows you to single-step through your code one statement at a time, trace variables, stop the execution at any time, and find errors in this way. In this exercise you will use the ebugger to trace through the program Exercise . Download the file DebuggingExerciae.java and create a new project . Open DebuggingExercise.java and try to run it. You will sec that it compiles but does not run . Check that you have a Debug button in the top right corner of your Eclipse window, beside the Java button. If you don't, select Window -Open Perspective - Debug . Click on the Debug button to change to the Debug view. You can, at any time, switch back to the Java view by clicking on the Java button in the top right corner. . In the window displaying your code, you will now add a breakpoint to the line for (int j-l; jStep 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