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 mainString args
int n ;
tryNumbern;
n;
tryNumbern;
public static void tryNumberint n
try
checkPositiveNumbern;
System.out.printlnn is positive.";
catch lllegalArgumentException e
System.out.printlnError: egetMessage;
public static void checkPositiveNumberint number
if number
throw new IllegaArgumentExceptionnumber is negative.";
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
