Question: JAVA CODING: (20 points) This exercise practices using try-catch block to capture a situation when an object reference is initialized to null. This exercise also

JAVA CODING:

JAVA CODING: (20 points) This exercise practices using try-catch block to capturea situation when an object reference is initialized to null. This exercise

(20 points) This exercise practices using try-catch block to capture a situation when an object reference is initialized to null. This exercise also demonstrates the use of multiple try-catch blocks, importance of catch blocks orders, and error messages from the default Exception handling 7. Steps 1. Download the program Assign5_7TryCatch.java from eLearn and run it. It should crash with a message. (0 point) 2. Click on the error message (last line) should bring you to the i.tostring() evil Comment on what happen. (trip NullPointerException: I is pointing to null) without try catch block) (2 points) i. 3. Comment out the "evil line" (line 15) Comment what happen (Caught by NullPointerException - (1st one) then jump to finally(3points) i. 4. Comment out the e.printStackTrace): and uncomment it back and observe the difference 5. Change 100 to null (line 23) and run it, explain what happen 6. Add another catch block before finally ( line 34) (3 points) i. Describe what you observe and explain.( 2 points) i. Describe what you observe and explain. 2 points) catch (Exception x) Systemoerrprintln(" I am Exception !!!"); x.printStackTrace) 7. Run it and does it trigger the Exception error? Describe what happen (2 points) 8. Change the order of the two catches (put NullPointerException) after the Exception, what happen? (3 points) 9. Put them back in a right order. Now add new line int y 9/0; in front of i-100; run it and explain what happen. 3 points)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!