Exception Hierarchy

Previous
Next

Exceptions Hierarchy:

  • Java API is providing pre-defined Exception classes and Error classes.
  • Java.lang.Throwable is the super class of all exception classes.
  • Exception and Error are the direct extensions (sub classes) of Throwable.
  • We cannot handle Errors.
  • We can handle only Exceptions.
  • Exception classified into
    • Checked Exceptions
    • Unchecked Exceptions
  • Child class of RuntimeException becomes unchecked exception.
  • The exception class which is not child of RuntimeException is called Checked Exception.

Note: We briefly discuss about Checked and Unchecked exceptions in following concepts.

Why we cannot handle errors?

  • Exception is a runtime error.
  • Exception occurs while application is running.
  • In case of Error, we cannot run the application.
  • For example.
    • If main() is not defined, we cannot execute the code called “Error”
    • If the memory is Full, program cannot run called “Error”
    • If the class is not present that we are accessing results “Error”
class Test 
{
	// no main...
}

Compile: No error
Run: Error - no main() method
Previous
Next

Add Comment

Courses Enquiry Form