class ex
{
public static int quotient(int a,int b)
{
if(b==0)
{
throw new ArithmeticException("divide by zero") ;
}
return a/b;
}
public static void main(String args[])
{
int c;
int a=5,b=0;
try
{
c=quotient(a,b);
System.out.println("the value of a/b is "+c);
}
catch(ArithmeticException e)
{
System.out.println("the b value can not be negative :");
System.out.println(" :"+e.getMessage());
System.out.println(" :"+e.toString());
e.printStackTrace();
}
finally
{
System.out.println("hello finally is executed ");
}
}
}
{
public static int quotient(int a,int b)
{
if(b==0)
{
throw new ArithmeticException("divide by zero") ;
}
return a/b;
}
public static void main(String args[])
{
int c;
int a=5,b=0;
try
{
c=quotient(a,b);
System.out.println("the value of a/b is "+c);
}
catch(ArithmeticException e)
{
System.out.println("the b value can not be negative :");
System.out.println(" :"+e.getMessage());
System.out.println(" :"+e.toString());
e.printStackTrace();
}
finally
{
System.out.println("hello finally is executed ");
}
}
}