What is the exception class hierarchy in Java (Throwable, Error, Exception, RuntimeException)?
Must Know🌱 FresherThrowable
├── Error (JVM-level problems -- don't try to recover)
│ └── OutOfMemoryError, StackOverflowError, ...
└── Exception
├── RuntimeException (UNCHECKED -- programming errors)
│ └── NullPointerException, ArrayIndexOutOfBoundsException,
│ ClassCastException, IllegalArgumentException, ...
└── (everything else) (CHECKED -- must catch or declare)
└── IOException, SQLException, ...Error represents serious problems the JVM itself hits (out of memory, stack overflow) that application code generally shouldn't try to catch/recover from. Exception is for conditions application code is expected to handle — split into checked and unchecked (see the next question).