Question: deffernce between checked and unchecked exception in java



Share on Google+Share on Google+

Nikhilkumar S Pakhale
deffernce between checked and unchecked exception in java
2 Answer(s)      5 years and 10 months ago
Posted in : Java Beginners

What is deffernce between checked and unchecked exception in java please explain by example

View Answers

July 22, 2011 at 12:40 PM


1)These are the exceptions which occur during the compile time of the program whereas Unchecked exceptions are the exceptions which occur during the run time of the program.

2)Checked exceptions must be explicitly caught or propagated as described in Basic try-catch-finally Exception Handling. Unchecked exceptions do not have this requirement. They don't have to be caught or declared thrown.

For more information, please go through the following link:

Checked and Unchecked Exceptions

September 15, 2012 at 12:08 AM

I strongly disagree. All exceptions occur at run time only.

The actual difference is a bit complicated.

Checked exceptions are the exceptions which are well known and likely to occur in some circumstance when the programmer uses some methods of the Java API. In such scenarios, the programmer must declare that his code can throw a checked exception at run time. This declaration is a compile - time check made by the java compiler for surity on java's robustness. If you are using methods which are likely to throw some checked Exception as specified in their throws clause, you must either handle them or specify in throws.

Specifying a throws is actually showing the compiler your awareness of the possibility that your method may throw an exception. At the same time, invokers of your method will find it easy to anticipate what all they need to handle as you are not handling but specifying in throws.

Thus we need to specify throws statement if we do not handle a checked exception.

However Runtime exceptions (Unchecked Exceptions) can occur any time and are actually coding bugs so should actually not be handled using catch block instead should be handled by writing bug-free code.

This can be a very harsh statement but still I stand to it:

"Runtime Exceptions should not be handled".

Instead they should be eradicated from code by changing code appropriately.


Related Tutorials/Questions & Answers:
deffernce between checked and unchecked exception in java
deffernce between checked and unchecked exception in java  What is deffernce between checked and unchecked exception in java please explain by example
unchecked exception
unchecked exception  What happens if the service method throws an unchecked Exception
checked and uncheked exception
checked and uncheked exception  please give some information about checked and unchecked exception
Java exception
Java exception  What is the difference between Checked and Unchecked exception
Question on Checked Exception
Question on Checked Exception   why checked exception force to put try and catch block ? Please send me answer
Jsp-delete checked checkboxes and display UNCHECKED checkboxes in table as well as in store that unchecked checkboxes in ARRAYLIST
Jsp-delete checked checkboxes and display UNCHECKED checkboxes in table as well as in store that unchecked checkboxes in ARRAYLIST  I have a table... in ARRAYLIST. I want to delete checked checkboxes.And store all unchecked checkboxes
Making Exceptions Unchecked - java tutorial,java tutorials
below types of built-in exception in java : 1. Unchecked Exception 2. Checked...Checked and Unchecked Exception In this section, you will learn Checked and Unchecked Exceptions in java and how to handle it. The Exception is a condition
exception  chek in and check out exception in java   Please visit the following link: Checked and Unchecked Exception
Difference between error and exception ????????
Difference between error and exception ?  Can we handle a error in java if yes than give an code of an example? Difference between error and exception handling.......   Exceptions are things you can create/throw
Java Exception - Java Beginners
we are comeing to checked/unchecked exception here we findout main use for throw/throws. when we raise the checked exception using throw here before raising... is checked exception,here we can not stmt "throws IlligalArgumentException
Java Exception
Java Exception  Explain about checked and unchecked Exceptions with Examples?   Checked Exceptions - These are the exceptions which occur... that whether the program contains handlers for checked exceptions
Exception handling in java
and catch() block. We are handle of exception checked and unchecked exception... operator. There are two types of exception:- Checked Exception. Unchecked...Exception handling in java We are going to discus about Exception handling
Java Exception
Java Exception  Why Errors are Not Checked
Java Exception
Java Exception  Why Runtime Exceptions are Not Checked
Difference between throw and throws in java.
Difference between throw and throws in java. Throws and throw both are keywords in java, used for handling the exception.  When a method is not able to handle the checked exception, it should declared with throws keyword
Java exception
Java exception  What is the difference between exception and error
Double-checked locking,java tutorials,java tutorial
Double-checked Locking Lets us have a look of Singleton pattern, In Singleton pattern we used some type of synchronization in java, so that only only one... create an instance, remember it is not checked at that time. Therefore we
List of Java Exception
are the list of various checked exception that defined in the java. lang package... List of Java Exception       Exception in Java are classified on the basis of 
List of Java Exception
- Following are the list of various checked exception that defined in the java. lang... List of Java Exception     ...; the exception handled by the java compiler. Java consists of the following type
Error and Exception in Java - Java Beginners
| | RuntimeExce(Unchecked) Checked(IoExce...Error and Exception in Java  Hi, What is the base class for Error and Exception? Thanks   hello. Throwable is the super class
Exception Java
Exception Java  Hi, What are the Exception Java? Thanks   Hi, Read it at Java Exception. Thanks
Java Exception
Java Exception  Which is superclass of Exception
Java exception
Java exception  Can an exception be rethrown
Java exception
Java exception  What happens if an exception is not caught
java Exception handling - Java Beginners
java Exception handling  what is the difference between throw... an exception manually where as throws is used in the case of checked exceptions to re-intimate the compiler that we have handled the exception. For more information
java exception
java exception   define an exception called no match exception tat z... { public static void main(String[] args) throws Exception { String z="Hello"; if(!z.equals("India")){ throw new Exception
user defined unchecked exception  can we create user defined unchecked exceptions? if so what is the exact use of it in real time?   Please visit the following links:
Java exception handling
Java exception handling  What is the difference between throw and throws keywords
Java Exception
Java Exception  What are monitors
Java sql Exception
Java sql Exception  difference between sql exception class and sql warning class
Java Spring Hibernate Struts Training Apache Commons ioutils maven dependency Read/Convert an inputStream to a String What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017 Java brief history Best Reasons to learn Java Java Example Codes and Tutorials in 2017 How do I read a large file quickly in Java? Is learning Java worthwhile? How to create first Java Program? Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include?


Advertisement null