Question: 1 (a) Look at the source code below and answer the following questions: 11 // Approach A 2 if (my Reference != null) { /*

1 (a) Look at the source code below and answer the following questions: 11 // Approach A 2 if (my Reference != null) { /* Handle null */ } 3 else { System.out.println(myReference.getID()); } // Approach B 6 try 7 { 8 System.out.println(myReference.getID()); 10 catch(NullPointerException npe) { /* Handle null */ } i. Is NullPointerException a checked exception? ii. Which approach (A or B) is the correct way to process a NullPointerException? iii. Provide a reason why you would this approach. (b) Discuss the advantages and disadvantages of Automatic Resource Management. [01] [02] [02] [05]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
