Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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

image text in transcribed

image text in transcribed

(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 i. Comment on what happen. (trip NullPointerException: I is pointing to null) without try catch block) (2 points) 3. Comment out the "evil line" (line 15 i. Comment what happen (Caught by NullPointerException - (1st one) then jump to finally (3points) 4. Comment out the e.printStackTrace(); and uncomment it back and observe the difference 5. Change i 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) System.err.println(" I am Exception! ! "); x.orintstackTrace (); 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) (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 i. Comment on what happen. (trip NullPointerException: I is pointing to null) without try catch block) (2 points) 3. Comment out the "evil line" (line 15 i. Comment what happen (Caught by NullPointerException - (1st one) then jump to finally (3points) 4. Comment out the e.printStackTrace(); and uncomment it back and observe the difference 5. Change i 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) System.err.println(" I am Exception! ! "); x.orintstackTrace (); 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

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

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

1 What is meant by systematic training?

Answered: 1 week ago

Question

2. Why has the conflict escalated?

Answered: 1 week ago

Question

1. How will you, as city manager, handle these requests?

Answered: 1 week ago