• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

SoftwareTestingo - Interview Questions, Tutorial & Test Cases Template Examples

SoftwareTestingo - Interview Questions, Tutorial & Test Cases Template Examples

  • Home
  • Test Case Examples
  • Interview Questions
  • Interview Questions Asked
  • Java
  • Selenium
  • Manual Testing
  • SQL Tutorial For Beginners
  • Difference
  • Tools
  • Contact Us
  • Search
SoftwareTestingo » Java » Java Tutorial » Exception Error Hierarchy In Details in Java Updated

Exception Error Hierarchy In Details in Java Updated

Last Updated on: March 15, 2019 By Softwaretestingo Editorial Board

What We Are Learn On This Post

  • Error Hierarchy In Java
  • java.lang.Throwable
  • java.lang.Exception
  • java.lang.Error

Error Hierarchy Exception In Details in Java Updated

In this article, we will discuss the exception hierarchy in detail with figure and explanation

Error Hierarchy In Java

The Throwable class is the root class for every exception and it branches out to 2 main categories i.e.;

  1. Exception
  2. Error

java.lang.Throwable

  • Throwable is the root class for exception & it’s sub-type and error & it’s sub-types
  • In other words, it is a superclass for exception & error
  • java.lang.The throwable class extends java.lang.Object class (as shown in the above figure)
  • It defines 2 subclasses i.e.; Exception and Error

java.lang.Exception

  • java.lang.Exception is a superclass for all types of Exception
  • It extends java.lang.Throwable class
  • The exception is due to programmatic logic
  • And it is recoverable
  • An exception are categorized into a checked and unchecked exception
  • Example: RuntimeException, SQLException, IOException, FileNotFoundException, ArithmeticException, NullPointerException
Check: ClassCast Exception

java.lang.Error

  • java.lang.Error is a superclass for all types of Error
  • It extends java.lang.Throwable class
  • Error is due to lack of system resources
  • And it is non-recoverable
  • All error falls into unchecked exception category, as it is raised due to lack of system resources at runtime
  • It is out of programming scope as such type of error can’t predict, maybe well-planned care can be taken to avoid this kind of Error
  • Example: VirtualMachineError, AssertionError, ExceptionInInitializerError, StackOverflowError, OutOfMemoryError, LinkageError, InstantiationError

Note: the above-mentioned Exception and Error are again categorized into checked and unchecked exceptions

    Filed Under: Java Tutorial

    Reader Interactions

    Leave a Reply Cancel reply

    Your email address will not be published. Required fields are marked *

    Primary Sidebar

    Join SoftwareTestingo Telegram Group

    Categories

    Copyright © 2023 SoftwareTestingo.com ~ Contact Us ~ Sitemap ~ Privacy Policy ~ Testing Careers