What is the difference between an unchecked exception and a checked exception




















Interfaces in Java. Keywords in Java. Exception Handling in Java. Collection Framework. Multi-threading in Java. Table of Contents. Save Article. Improve Article. Like Article. Previous Types of Exception in Java with Examples. Next Try, catch, throw and throws in Java. Key Differences Between Checked and Unchecked Exception Checked exceptions are in knowledge of compiler whereas, Unchecked exceptions are not in knowledge of compiler.

Except RuntimeException and Error class all the classes are checked exception. On the other hand, RuntimeException and Error classes are unchecked exceptions. If the checked exceptions are not handled by the code then the compiler objects. If checked exceptions occur in the code the code will not compile whereas, even if unchecked exceptions are not handled by the code the compiler still compiles the code. Leave a Reply Cancel reply Your email address will not be published.

Except "RuntimeException" class all the child classes of the class "Exception", and the "Error" class and its child classes are Checked Exception. Difference between Checked and Unchecked Exceptions in Java. Get Free Tutorials by Email Email:. Advertisements help running this site for free. To view the content please disable AdBlocker and refresh the page.

These types of exceptions cannot be a catch or handle at the time of compilation, because they get generated by the mistakes in the program. Checked Exceptions and Unchecked Exceptions both can be handled using try, catch and finally. Unchecked Exceptions are mainly programming mistakes.

Unchecked Exceptions can be ignored in a program but Unchecked Exceptions cannot be ignored in a program. Summary This article explains Exceptions and their types in Java. View All. Satendra Singh Bhati Updated date Jul 22, Exceptions are the undesirable events during the execution of the program.

In Java when an exception occurs, an exception object is created. Checked Exceptions occur at the runtime of the program.



0コメント

  • 1000 / 1000