Checked and Unchecked Exception in Java

 Checked Exception- probable Exception which should be checked at compile time for any     unwanted situation need to be handled. Those are taken care by compiler. 
 For e.g. We are doing any file reading . There is a possibility ,file can't be found at a given place.
 So, compiler force us to do handle this exception otherwise it will be a compilation error. 
 We can do either by throws keyword or try-catch block.


Unchecked Exception-Exception thrown at run time ,i.e. compiler is unable to check those error at compile time . For e.g.logic error, a number divided by zero throws exception at run time.

Refer-
https://www.geeksforgeeks.org/checked-vs-unchecked-exceptions-in-java/


Comments

Popular posts from this blog

Polymorphism

Static Keyword in Java