Junior — Middle
Can you list the main hierarchy of exception classes used?
sobes.tech AI
Answer from AI
In Java, the class hierarchy of exceptions starts with the base class Throwable. From it, two main subclasses are inherited:
Error— errors that are usually not handled by the application (e.g.,OutOfMemoryError).Exception— exceptions that can and should be handled.
In turn, Exception is divided into:
- Checked exceptions, which need to be explicitly handled or declared (e.g.,
IOException). - Unchecked exceptions, descendants of
RuntimeException(e.g.,NullPointerException,IllegalArgumentException).
Example hierarchy:
java.lang.Throwable
├── java.lang.Error
└── java.lang.Exception
├── java.lang.RuntimeException
└── other checked exceptions