Assignment Oop6
Assignment Oop6
*;
class ExceptionEx
{
public void Arithmatic()
{
int num1 , num2;
int result;
Scanner sc = new Scanner(System.in);
System.out.println("Enter Two Numbers ::");
try
{
num1=sc.nextInt();
num2=sc.nextInt();
result=num1/num2;
System.out.println("The result is "+result);
}
catch(ArithmeticException e)
{
System.out.println("Number cannot be divided by zero");
}
}
catch (NumberFormatException e)
{
System.out.println("NumberFormatException occurred");
}
}
public class Excep
{
public static void main(String[] args)
{
ExceptionEx e = new ExceptionEx();
OUTPUT:
Enter the Index No. of Element which you want to print ::3
1 is present at given index
successfully completed
successfully completed
successfully completed
successfully completed