0% found this document useful (0 votes)
55 views2 pages

Discussion Forum Unit 1 Cs2203

The computer program is responsible for catching and handling exceptions that occur during execution to prevent crashing. Exceptions are errors that arise and affect program flow. The computer does not handle exceptions automatically; we must write code using try and catch statements to catch exceptions and allow the program to continue running rather than crashing. For example, a simple math program will crash when it tries to divide by 0, but using try and catch allows it to handle the exception and finish running without crashing.

Uploaded by

Julio Louzano
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views2 pages

Discussion Forum Unit 1 Cs2203

The computer program is responsible for catching and handling exceptions that occur during execution to prevent crashing. Exceptions are errors that arise and affect program flow. The computer does not handle exceptions automatically; we must write code using try and catch statements to catch exceptions and allow the program to continue running rather than crashing. For example, a simple math program will crash when it tries to divide by 0, but using try and catch allows it to handle the exception and finish running without crashing.

Uploaded by

Julio Louzano
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

In my conception, the computer program is responsible for catching and handling exceptions.

The computer program is the one responsible for catching and handling exceptions. An
“exception” is simply an “error” that happens to arise during the execution of the computer
program causing it to crash or affect the flow in which the program works (Eck, 2019).

Thinking about it, the computer does not handle exceptions automatically, basically we must
code the catching and handling exceptions making the computer program do it.

To be clearer I will show an example of exceptions and crash, using simple math, the program
cannot divide 6 by 0 in line 5 of this program causing the final message as shown.

And the other expressions like 6/3 and 6/2 are not printed because the program crash.

By using try and catch statement, we can catch, and handle exceptions as shown:
In this case the message displays all the results, using catch try and catch statement 6/0 came
with an exception but we can handle it, causing that the program does not crash, and the
outputs are shown in the console.

Reference

Eck, D. J. (2019). Introduction to programming using Java, version 8.1. Hobart and William
Smith Colleges. http://math.hws.edu/javanotes.

You might also like