Junior — Middle
Can you explain the functional role and features of initialization blocks in Java?
sobes.tech AI
Answer from AI
In Java and the hierarchy of exceptions, the base class is java.lang.Throwable, which has two main subclasses:
Error— errors that are usually not handled by applications (e.g.,OutOfMemoryError).Exception— exceptions that can and should be handled.
Exception is further divided into:
- Checked exceptions — require explicit handling or declaration (
IOException,SQLException). - Unchecked exceptions — subclasses of
RuntimeException, do not require handling (NullPointerException,IllegalArgumentException).
The structure looks like this:
Throwable
├── Error
└── Exception
├── RuntimeException (unchecked)
└── Other exceptions (checked)
This allows the compiler and developers to understand which exceptions need explicit handling and which do not.