Question: As per given code fill in the blank space and find the error in code and rewrite it (java) public class W11Exception2 { public static

As per given code fill in the blank space and find the error in code and rewrite it (java)

public class W11Exception2 {

public static void main(String[] args)

{

Scanner input=new Scanner(System.in);

System.out.println("enter two integer no");

int no1=input.nextInt();

int no2=input.nextInt();

try

{

int s=division(no1,no2);

System.out.println("no1/no2="+s);

}

catch(ArithmeticException e)

{

System.out.println("an int can not divide by zero"+e);

}

finally

{

System.out.println("this is finally block");

}

}

public static int division(int a,int b) throws ArithmeticException

{

if(b == 0)

throw new ArithmeticException("divisior can not be zero");

return a/b;

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!