Program To Show Exception Handling

  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Program To Show Exception Handling as PDF for free.

More details

  • Words: 88
  • Pages: 3
PROGRAM TO SHOW EXCEPTION HANDLING public class DivideException {

public static void main(String[] args) {

division(100,0); System.out.println("Main Program Terminating");

} public static void division(int totalSum, int totalNumber) {

int quotient = -1; System.out.println("Computing Division."); try {

quotient = totalSum/totalNumber; System.out.println("Result is : "+quotient);

} catch(Exception e) {

System.out.println("Exception : "+ e.getMessage());

} finally {

if(quotient != -1) {

System.out.println("Finally Block Executes"); System.out.println("Result : "+ quotient);

} else { } } }

System.out.println("Finally Exception Occurred”);

}

OUTPUT Computing Division. Exception: / by zero Finally Exception Occurred Main Program Terminating

Related Documents

Exception Handling
November 2019 33
Exception Handling
November 2019 36
Exception Handling
June 2020 26
Exception Handling
June 2020 22