"Hi, Amigo. Yesterday I was a bit tipsy, so I'm afraid I've messed up your tasks. But I hope you won’t be mad at me and will complete them all. It's for your own good. Here they come."
15
Task
New Java Syntax,
level 15,
lesson 8
Locked
Exceptions
The method throws two exceptions that inherit Exception, and two exceptions that inherit RuntimeException: NullPointerException, ArithmeticException, FileNotFoundException, URISyntaxException.
You need to catch NullPointerException and FileNotFoundException, but not catch an ArithmeticException or
15
Task
New Java Syntax,
level 15,
lesson 8
Locked
Catching a group of exceptions
1. There are three exceptions that successively inherit Exception.
2. The Exception1 class extends Exception
3. The Exception2 class extends Exception1
4. The Exception3 class extends Exception2
5. There is a method with the following signature:
public static void method1() throws Exception1, Except
15
Task
New Java Syntax,
level 15,
lesson 8
Locked
Catching checked exceptions
In the handleExceptions method, handle all checked exceptions.
You need to display the checked exception that occurs.
You can only use one try-catch block
15
Task
New Java Syntax,
level 15,
lesson 8
Locked
Catching unchecked exceptions
In the handleExceptions method, handle all unchecked exceptions.
You need to use the printStack method to display the stack trace of the exception that occurs.
You can only use one try-catch block
15
Task
New Java Syntax,
level 15,
lesson 8
Locked
Catching custom exceptions
1. Analyze the exceptions thrown by the BEAN.throwExceptions method.
2. In the handleExceptions method, call the BEAN.throwExceptions method and handle the exceptions:
2.1. if there is a FileSystemException, then log it (call the BEAN.log method) and rethrow
2.2. if there is a CharConversionExceptio
15
Task
New Java Syntax,
level 15,
lesson 8
Locked
Creating your own exceptions
There are four classes: MyException, MyException2, MyException3, and MyException4.
Inherit the classes so that you get any two checked exceptions and any two unchecked exceptions.
GO TO FULL VERSION