jump to navigation

Difference between error and an exception? October 5, 2006

Posted by Allu 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.).

Advertisements

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

Jerinho - January 22, 2011

it’s not that a class cant be declared as private or protected, it is a class can only be declared either as public (with “public”) or private (w/o “public”). the only no is the protected class

by their meaning, it is used both in inheritance and composition purpose. public class mean file class, which can be used universally (why not). to declare any other public class, we have to create another class file

private class (or maybe it suit more if we call it protected class), is any other class those we declare beside the public class in same file, n that public one is the only class who can use those privates

why not java use the default (remove “public”) for public class? because they even dont did so for method. so to not confusing the user, they just use same rule for both of them

thats all what i knew. correct me if u see sumthing wrong. n as u know, it’s all about JAVA n idk what about others

Jerinho - January 22, 2011

Sorry wrong number. actually it is for 11. my bad #-P

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

arsenal - February 26, 2010

if a calss is declared private then its of no use writing that class. because private cannot be accessed outside class.

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

18. nagesh - April 13, 2010

how wil i remove session?
is there any methods like remove() and invalidate() to remove the session?
if is there what is the difference between them?

19. Manikandan - May 1, 2010

thanx for the explanation..

20. data - September 30, 2011

data

21. Sudip - October 17, 2011

Exceptions:

Can be checked or unchecked
Indicate an error caused by the programmer
Should be handled at the application level

Errors:

Are always unchecked
Usually indicate a system error or a problem with a low-level resource
Should be handled at the system level, if possible


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: