Answer to Question #224062 in Java | JSP | JSF for Baarish

Question #224062

Write a program to show the use of try statements that emphasizes the sequence 

of checking for catch handler statements.


1
Expert's answer
2021-08-07T03:28:48-0400



package error;


import java.util.Scanner;
public class Error {


    
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        
        int value1, value2;
        try {
         //Try block 
         System.out.println("Enter a value to divide by 25");
         value2 = input.nextInt();
         value1 = 25 / value2;
         System.out.println("The answer is \t"+value1);
         System.out.println("Try Block:: End");
      }
      catch (ArithmeticException e) { 
         
         System.out.println("ArithmeticException :: Divide by Zero!!");
      }
     
   }
    }


    
    

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS