What are the differences between unchecked exception, checked exception, and errors?
Answer Posted / 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 View All Answers
What about method local inner classes or local inner classes in java?
Why is multithreading important?
What is bubble sort in java?
Why deletion in linkedlist is fast than arraylist?
What two classes are used to read data only?
Explain wait() method of object class ?
What is the final variable?
Why should I use abstract class?
String and stringbuffer both represent string objects. Can we compare string and stringbuffer in java?
When arithmeticexception is thrown?
How do you declare an empty string?
How many JVMs can run on a single machine and what is the Just-In-Time(JIT) compiler?
What is the purpose of static methods and variables?
Why does the integer quotient -0/3 yield 0, but the double quotient -0.0/3.0 yields – 0.0?
Why singleton is not thread safe?