Question: What will be the output for the following Java programming. Include explanation in your answer. public class Exception NegativeNumber { public static void main (

What will be the output for the following Java programming. Include explanation in your
answer.
public class Exception NegativeNumber {
public static void main(String[] args){
int n =25;
tryNumber(n);
n=-10;
tryNumber(n);
}
public static void tryNumber(int n){
try {
checkPositiveNumber(n);
System.out.println(n +" is positive.");
} catch (lllegalArgumentException e){
System.out.println("Error: "+ e.getMessage());
}
}
public static void checkPositiveNumber(int number){
if (number 0){
throw new Illega(ArgumentException(number +" is negative.");
}
}
}
What will be the output for the following Java

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!