Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions

Question

13-4 What are alternative methods for building information systems?

Answered: 1 week ago