Войти
  • 137116Просмотров
  • 2 года назадОпубликованоTelusko

#79 Exception Hierarchy in Java

Check out our courses: Java Spring Boot AI Live Course: Coupon: TELUSKO20 (20% Discount) AI Powered DevOps with AWS - Live Course :- Coupon: TELUSKO20 (20% Discount) Master Java Spring Development : Coupon: TELUSKO20 (20% Discount) For More Queries WhatsApp or Call on : +919008963671 website : Udemy Courses: Spring: Java:- Java Spring:- Java For Programmers:- Python : Git : Docker : Instagram : Linkedin : TELUSKO Android App : TELUSKO IOS App : Discord : In this lecture we are discussing about hierarachy of exception: -- In Java, exceptions are objects that represent exceptional situations that can occur during program execution. The Java language provides a hierarchy of exception classes that are used to represent different types of errors and exceptional situations. #Important points -- Every class extends Object class so, Throwable class by default extends Object -- The top-level class in the Java exception hierarchy is the Throwable class. All exception classes in Java are subclasses of the Throwable class. -- The Throwable class has two subclasses: Error and Exception. -- The Error class represents serious errors that cannot be handled by the program, such as OutOfMemoryError or StackOverflowError. -- The Exception class represents exceptions that can be caught and handled by the program. -- The Exception class has many subclasses that represent specific types of exceptions. Some common subclasses of Exception include RuntimeException, IOException, SQLException, and NullPointerException. -- Exception classes in Java can be either checked or unchecked. Checked Exception: Checked exceptions are those that are checked at compile-time, meaning the compiler ensures that the programmer handles the exception by either catching or declaring it in the method signature using the throws keyword. Examples of checked exceptions include IOException, SQLException, and ClassNotFoundException. UnChecked Exception: unchecked exceptions are not checked at compile-time, and the compiler does not force the programmer to handle them. Examples of unchecked exceptions include NullPointerException, ArrayIndexOutOfBoundsException, and ArithmeticException. hierrachry of exception Object class | Throwable --------- --------- | | Error Exception ----------- ---------------------------------------------- | | | RuntimeEception(uncheked) SQLException(checked) IOException(checked) ArithmeticException NullPointerException ArrayIndexOutOfBoundsException Github repo : More Learning : Java :- Python :- Django :- JavaScript :- Node JS :- Rest Api :- Servlet :- Spring Framework :- Design Patterns in Java :- Docker :- Blockchain Tutorial :- Corda Tutorial:- Hyperledger Fabric :- NoSQL Tutorial :- Mysql Tutorial :- Data Structures using Java :- Git Tutorial :- Donation: PayPal Id : navinreddy20