Saturday, 12 April 2014

Exception Handling Multiple catch Blocks

java.lang.Exception----->java.lang.RunTimeExceptions


public class EXCEPTIONDemo 
{
public void show(int a)
{
try
{
System.out.println(5.5);
}
catch(ArithmeticException e)
{
System.out.println("ArtmeticException"+e.getMessage());
}
catch(NumberFormatException e)
{
System.out.println("NumberFormatException"+e.getMessage());
}
catch(ClassCastException e)
{
System.out.println("ccException"+e.getMessage());
}
catch(NullPointerException e)
{
System.out.println("NpException"+e.getMessage());
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println("aiotofbdsException"+e.getMessage());
}
catch(StringIndexOutOfBoundsException e)
{
System.out.println("NumberFormatException"+e.getMessage());
}
catch(IllegalArgumentException e)
{
System.out.println("NumberFormatException"+e.getMessage());
}
finally
{
System.out.println("final alweays executes");
}
}
public static  void main(String[] args) 
EXCEPTIONDemo eXCEPTIONDemo=new EXCEPTIONDemo();
eXCEPTIONDemo.show(5);
}

 

}

No comments:

Post a Comment