September 2005
Beginner
576 pages
13h 6m
English
| Q1: | Is it possible to create your own exceptions? |
| A1: | You can create your own exceptions easily by making them a subclass of an existing exception, such as Exception, the superclass of all exceptions. In a subclass of Exception, there are only two methods you might want to override: Exception() with no arguments and Exception() with a String as an argument. In the latter, the string should be a message describing the error that has occurred. |
| Q2: | Why doesn't this hour cover how to throw and catch errors in addition to exceptions? |
| A2: | Java divides problems into Errors and Exceptions because they differ in severity. Exceptions are less severe, so they are something that should be dealt with in your programs using try-catch or throws. Errors, on ... |
Read now
Unlock full access