Question
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: returned from Method1.); } public static
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: returned from Method1."); }
public static void Method1() { System.err.println("\tIn Method1: calling Method2."); Method2(); System.err.println("\tIn Method1: returned from Method2."); }
public static void Method2() { System.err.println("\t\tIn Method2: calling Method3."); Method3(); System.err.println("\t\tIn Method2: returned from Method3."); }
public static void Method3() { System.err.println("\t\t\tIn Method3: Entering.");
//Add code to throw an exception here.
System.err.println("\t\t\tIn Method3: Exiting."); } }
. Add code to Method3 that throws an unchecked exception by attempting to divide an integer by zero. Complie and run the program and note where the exception is thrown.
This is done using Java with Netbeans
Step 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