Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

What is exception propagation? Give an example of a class that contains

What is exception propagation? Give an example of a class that contains

at least two methods, in which one method calls another. Ensure that the subordinate method will call a predefined Java method that can throw a checked exception. The subordinate method should not catch the exception. Explain how exception propagation will occur in your example.

I am trying to get this JAVA code to pass an input from a conversion method to an addition method and if the user inputs anything besides an integer they will be prompted to use an integer but the exception must be caught in the addition method.

The code I have is here:

public class Example {
static void numberConversion(String input){
int number = Integer.parseInt(input);
System.out.println(“Your number is : “+number);
}
public static void secondMethod() {
try{
int z = numberConversion + 10;
}catch(java.lang.NumberFormatException e){
System.out.println(“Must input integer”);
System.out.println(z);
}

}

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println(“Enter an Integer: “);
String input = scanner.nextLine();
numberConversion(input);
}
}

 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"