if a program throw 2 exceptions can we handled it by user defined exception.for example
import java.util.*;
class WrongException extends Exception{
public WrongException(String s){
super(s);
}
}
public class UserDefinedException2{
public static void main(String s[]){
int a,b;
a=b=0;
Scanner ob=new Scanner(System.in);
System.out.print("Enter your age = ");
a=ob.nextInt();
try
{
if(a<=0)
throw new WrongException("age cannot be zero or nagetive");
System.out.print("age = "+a);
}
catch(WrongException e){
System.out.print(e);
}
}
}
the upper code handled an negetive and zero value exception.there exception can occure that throw InputMismatchException
then how we can handled it. now we will handled two exceptions my question is how two exception handle by user defined exception