Repaso
EspaƱol
Java CoreCoreJV-12

Which of these is a CHECKED exception?

Options

  1. NullPointerException
  2. IllegalArgumentException
  3. IOException (Correct option)
  4. ArrayIndexOutOfBoundsException

Answer

IOException

Why

Checked exceptions extend Exception (but not RuntimeException). The compiler FORCES you to either catch them or declare them with throws. IOException (files, network) is the classic one.

Unchecked exceptions extend RuntimeException (NullPointerException, IllegalArgumentException, IndexOutOfBounds...). They usually mean a bug in the code, and the compiler does not force you to handle them.

Error (like OutOfMemoryError) is for serious JVM problems; you normally do not catch it.

Remember

Checked = compiler forces you to handle. Unchecked = RuntimeException.

Key terms

Practice this question in Repaso