Checked Vs unchecked Exceptions with example in Java Interview Questions and Answers | Code Decode

Описание к видео Checked Vs unchecked Exceptions with example in Java Interview Questions and Answers | Code Decode

Difference between checked and unchecked exception is very commonly asked java interview questions in every interview

Udemy Course of Code Decode on Microservice k8s AWS CICD link:
https://openinapp.co/udemycourse

Course Description Video :
https://yt.openinapp.co/dmjvd

Difference between checked vs unchecked exceptions

Checked
Unchecked Exceptions
Another name
Checked exceptions are checked by the Java compiler so they are called compile time exceptions.
Unchecked exceptions are not checked by the compiler. These are called runtime exceptions.
When
Checked exceptions occur at compile time.
Unchecked exceptions occur at runtime.
Handled by
These types of exceptions can be handled at the time of compilation.
These types of exceptions cannot be catched or handled at the time of compilation, because they get generated by the mistakes in the program.
Handling
Must be handled in a try-and-catch block, or be thrown by the invoking method
Exception handling semantics are not required


Difference between checked vs unchecked exceptions

Checked
Unchecked Exceptions
Force
Java compiler forces us to handle these exceptions in some manner
A method is not forced by the compiler to declare the unchecked exceptions into the method declaration.
Hierarchy
They are all subclasses of Exception.
They are all subclasses of RuntimeException.
Scenario

Checked Exception represent scenario with higher failure rate

UnChecked Exception are mostly programming mistakes.
Throws clause
The throws clause on a method header must be included for checked exceptions that are not caught and handled in the method.
The throws clause on a method header is not mandatory


Checked
Unchecked Exceptions
Examples
File Not Found Exception
No Such Field Exception
Interrupted Exception
No Such Method Exception
Class Not Found Exception


No Such Element Exception
Undeclared Throwable Exception
Empty Stack Exception
Arithmetic Exception
Null Pointer Exception
Array Index Out of Bounds Exception

Most Asked Core Java Interview Questions and Answers:    • Core Java frequently asked Interview ...  
Advance Java Interview Questions and Answers:    • Advance Java Interview Questions  

Java 8 Interview Questions and Answers:    • Java 8 Interview Questions(New Features)  

Hibernate Interview Questions and Answers:
   • Hibernate Interview Questions Java  

Spring Boot Interview Questions and Answers:
   • Advance Java Interview Questions  

Angular Playlist:    • Angular Course Introduction || Angular 8  
SQL Playlist:    • SQL Interview Questions and Answers  

GIT:    • GIT  

Subscriber and Follow Code Decode
Subscriber Code Decode: https://www.youtube.com/c/CodeDecode?...
LinkedIn :   / codedecodeyoutube  
Instagram:   / codedecode25  

#exceptions #java #codedecode

Комментарии

Информация по комментариям в разработке