• Exception and error occur when an unexpected or abnormal event takes place during the execution of the application
  • In Java, exceptions and errors belong to the parent class Throwable
  • An exception can be classified into two types namely, checked (compile time) exceptions and unchecked (runtime) exceptions

Checked Exceptions

  • Belong to the base class Exception
  • They occur when there is an error found in code
  • These exceptions are identified by the compiler and can be handled by programmers

Unchecked Exceptions

  • Belong to the base class RuntimeException
  • They occur when an error arises during the execution of the program
  • These errors cannot be handled by programmers

Exception and Error Handling (Cont’d)

  • Errors in Java are caused due to irrecoverable conditions such as memory leak, LinkageError, etc. that cannot be handled in programs
  • Developers should ensure that exceptions are properly handled and do not disclose any information to the user/attacker
  • Attackers can make use of information gained from error messages to perform attacks
  • Information leakage can lead to social engineering exploits
  • Unhandled exceptions may result in abnormal termination of the application