CodeGym /Courses /Java Collections /Tasks | Level 8 | Lesson 4

Tasks | Level 8 | Lesson 4

Java Collections
Level 8 , Lesson 4
Available
10
Task
Java Collections, level 8, lesson 4
Locked
Fix coding errors
The NameIsEmptyException and NameIsNullException exceptions must be checked. All types of exceptions must be handled. Don't change the implementations of the main() and getNumberOfCharacters() methods. Only the order of the catch blocks in the main() method should be changed.
10
Task
Java Collections, level 8, lesson 4
Locked
Checked exceptions
Write the implementation of the veryComplexMethod() method. It must always throw a checked exception. Using the keyword throw to throw an exception is explicitly forbidden.
10
Task
Java Collections, level 8, lesson 4
Locked
Runtime exceptions (unchecked exceptions)
Write the implementation of the methodThrowsClassCastException() method. It must always throw a ClassCastException. Write the implementation of the methodThrowsNullPointerException() method. It must always throw a NullPointerException.
Comments (2)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
Justin Smith Level 41, Greenfield, USA, United States
18 February 2023
The first one is easy, but I found the other two to be fairly difficult, mostly just because I had no idea where to even begin (the explanation on the previous page about checked vs. unchecked exceptions is quite brief, to put it mildly).
Andrei Level 41
27 July 2021
Very nice exercises, helped with assimilating previous information.