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 the immediate superclass of Menu?

3 Answers  


What is update method and when it is called?

2 Answers   TCS,


What is method overloading and method overriding?

0 Answers  


what is the difference between the "protected and default" modifiers?

8 Answers  


public class Test { public static void main(String ar[]) { Integer a = 10; Integer b =10; Integer c = 145; Integer d = 145; System.out.println(a==b); System.out.println(c==d); } }

7 Answers   iGate,


List primitive java types?

0 Answers  


Difference between ‘>>’ and ‘>>>’ operators in java?

0 Answers  


What is “try and catch” in java

5 Answers   Cap Gemini, TCS,


What is connection class in java?

0 Answers  


Why do we use bufferedreader?

0 Answers  


Is binary a low level language?

0 Answers  


Can we create our own daemon thread?

0 Answers  


Categories