jump to navigation

Difference between error and an exception? October 5, 2006

Posted by :) in JAVA.
trackback

An error is an irrecoverable condition occurring at runtime. Such as OutOfMemory error. These JVM errors and you can not repair them at runtime. While exceptions are conditions that occur because of bad input etc. e.g. FileNotFoundException will be thrown if the specified file does not exist. Or a NullPointerException will take place if you try using a null reference. In most of the cases it is possible to recover from an exception (probably by giving user a feedback for entering proper values etc.).

Comments»

1. Prasad - October 11, 2006

Hi Allu,
This is good site.
Thanks for providing these kind of information at one place.
thanks

Regards
Prasad

2. santhosh - October 15, 2006

hi this is santhosh from banglore plz send some real time tips and applications regarding struts.how do u get ejb bean in struts.plz send immediately.plz send some projects specification that r related to banking or insurance or sales domain.and send an application how to design in struts.plz i m requesting u and i believe that u will send
thanks
bye………..

3. syed - November 2, 2006

hai,
1——can anyone explain me why should we go for collections?
2—–when should i use static blocks

4. TMS Raj - November 20, 2006

what is the difference between throw and throws in exception handling

5. TMS Raj - November 21, 2006

Hai,

Thanks for clarification about the throw and throws.
I have another question. How to create dsn(also how to check whether dsn created is succesful) for establishing the jdbc connection using the jdbcodbcbridge driver and do we need any .jar or other type of files in this regard.

6. pradeep - May 3, 2007

Hi ,
Srinivas this is good for interview going people .
thank u

7. raveendra budida - May 29, 2007

Hi sir can you tell me why threads are said to be lightweight and please tell me what is the difference between lightweight and heavyweight components.

8. chenna reddy . M - June 2, 2007

what is the difference between error and exception ?

9. Prasad Thakur - September 5, 2007

main difference is
In case of exception, we can use wxception handler to overcome the exception and continue with the normal execution of the program.
There might be some checked and some unchecked exceptions.
most of the exceptions can be handled.

but in case of error, there is no error handler as such to handle those.
There are some tipical error classes such as LinkerError,VirtualMachineError,ThreadDeath etc. can not be handled explicitly. These are irrecoverable.This is the main Difference.

NOTE–> If you know anything more then please let me know.

10. ravi - December 16, 2007

nice explanation
thank you

11. Varsha - January 9, 2008

why the class cannot be declared as private and protected?

venkatesh - May 14, 2009

bcz when we use private or protected the access of the class is limited.
when we use private we cant even try to call that class from other class
when we use protected we cant call the class from other package. but we
can use those sub classes of the protected classes any where.but by using public there is no restriction

12. Hafiz Usman Majeed - August 7, 2008

Difference Between Throws And Throw is That the preceeded one is used for specifying that a function will throw an exception of particular type such as
public void run() throws InterruptedException
{
try
{
//some code here which generates exception
}
catch()
{
throw InterruptedException()
}
}
The Key word throw is used for Rethrowing An Exception from child Function to parent(calling) function and managing it out there

13. Sridhar Reddy - September 1, 2008

Hi this is sridhar

can u give any real life example and real time example for Abstraction and Encapsulation………..

plz ASAP

14. Sridhar Reddy - September 1, 2008

Hi This is sridhar…….

Can u give clarification about Checked Exception and Unchecked Exceptions ……..

checked exceptions r compile time and Unchecked Exceptions r Run time. is it right………..?
but Exceptions are occurring at run time……..?

15. Kiran - October 6, 2008

Can u explain me about the Abtract class and interfaces?difference between them?

16. manoj - October 9, 2008

why sun provided errors and exceptions separately ? Why not given only exceptions ?

17. VV - December 24, 2008

Hi Srinu,

This info is looking good, I think you can provide some more info on this…

Thanks, VV