What are the differences between unchecked exception, checked exception, and errors?

Answers were Sorted based on User's Feedback



What are the differences between unchecked exception, checked exception, and errors?..

Answer / nashiinformaticssolutions

• An Unchecked exception inherits from RuntimeException (which extends from exception). The JVM treats RuntimeException differently as there is no requirement for the application code to deal with them explicitly.
• A checked exception inherits from the exception class. The client code has to handle the checked exceptions either in a try-catch clause or has to be thrown for the super-class to catch the same. A checked exception thrown by a lower class (sub-class) enforces a contract on the invoking class (super-class) to catch or throw it.
• Errors (members of the error family) usually appear for more serious problems, such as OutOfMemoryError (OOM), that may not be so easy to handle.

Is This Answer Correct ?    0 Yes 0 No

What are the differences between unchecked exception, checked exception, and errors?..

Answer / hr@tgksolutions.com

• An Unchecked exception inherits from RuntimeException (which extends from exception). The JVM treats RuntimeException differently as there is no requirement for the application code to deal with them explicitly.
• A checked exception inherits from the exception class. The client code has to handle the checked exceptions either in a try-catch clause or has to be thrown for the super-class to catch the same. A checked exception thrown by a lower class (sub-class) enforces a contract on the invoking class (super-class) to catch or throw it.
• Errors (members of the error family) usually appear for more serious problems, such as OutOfMemoryError (OOM), that may not be so easy to handle.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is cr keyboard?

0 Answers  


Is node a data type in java?

0 Answers  


Which browsers work with java?

0 Answers  


If I have 1000 objects and my requirement is to sort them quickly, then which collection would you recommend and why?

5 Answers   KPIT,


What is method overloading in JAVA? Why is it not present in C ?

0 Answers   Akamai Technologies,


What do u mean by variable?

0 Answers  


How use .contains in java?

0 Answers  


What is the difference between class & structure?

0 Answers  


What is a war file?

0 Answers  


When does a class need a virtual destructor?

0 Answers   Flextronics,


What is a treeset in java?

0 Answers  


What differences exist between iterator and listiterator?

0 Answers  


Categories