Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

import java.*; public class ExceptionTesterApp { public static void main(String args) { System.println(In main: calling Method1.);...

Intro to Java:(only need source code and will tip)(Two attachments: “ExceptionTesterApp.java” and an image of figure 14-7 for convenience) In this exercise, you'll experiment with ways to throw and catch exceptions:1.) Add code to Method3 that throws an unchecked exception by attempting to divide an integer by zero. Compile and run the program and note where the exception is thrown.2.) Delete the code you just added to Method3. Then, add a statement to this method like the one in figure 14-7 that creates an object from the RandomAccessFile class, but use the string "products.ran” in place of the path variable. The constructor for this class throws a checked exception named FileNotFoundException. Note the error message that indicates that you haven't handled the exception. If this error message isn't shown, compile the class to display the error message.3.) Add throws clauses to all of the methods including the main method. Then, run the program to see how a checked exception can propagate all the way out of a program. 4.) Add the code necessary to handle the FileNotFoundException in Method1. To do that, you'll need to remove the throws clauses from the main method and Method1, and you'll need to add a try statement to Method1 that catches the exception. The catch block should display an appropriate error message. Run the program to make sure the exception handler works.-Thank you very much

  • Attachment 1
  • Attachment 2
import java.io.*;public class ExceptionTesterApp {public static void main(String args) {System.err.println("In main: calling Method1.");Method1();System.err.println("In main:...
Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question