0% found this document useful (0 votes)
2 views7 pages

Lab Act Exception Final

The document discusses exception handling in Java, explaining the significance of the 'throws' keyword as a warning for potential errors. It highlights the need for custom error messages to provide specific information about issues in the program. Additionally, it describes the 'finally' block as a cleanup mechanism that executes regardless of whether an error occurs, ensuring proper resource management.

Uploaded by

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

Lab Act Exception Final

The document discusses exception handling in Java, explaining the significance of the 'throws' keyword as a warning for potential errors. It highlights the need for custom error messages to provide specific information about issues in the program. Additionally, it describes the 'finally' block as a cleanup mechanism that executes regardless of whether an error occurs, ensuring proper resource management.

Uploaded by

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

LabAct: Exception Handling

Task1:
Task2:
Task3:
Task4:
Task5:
PostLab Answers:

1. I think "throws" keyword is like a warning sign. It's saying, that this is part of the code
might have a problem and cause an error. You need to deal with it."It's kind of like a
warning sign. The part of the program that calls this code needs to be prepared to fix any
problems that might happen.
2. I think Java has built-in errors it can handle, but sometimes you need to create your own
custom errors for something specific to your program. Because these are custom errors
like special messages that give more information about what what is wrong, and they let
you decide how to fix the problem in your code.
3. Hmm, yes because "finally" block in Java is like a cleanup crew. Even if there's an error (
exception) or if things go smoothly, the finally block will run. It's important because it
helps clean up anything that might be left behind, it will like closing files, so your
program doesn't get messy. It runs right after the "try" block if everything works, or after
the "catch" block if there's an error. And even if the program crashes before it's
supposed to, the finally block will still try to clean up things as best it can.

You might also like