33
Error vs Exception
One of the most difficult parts of programming languages is to know the difference between Error and Exception. I used to get confused a lot about this. So, to help my mates to overcome this problem, I thought of writing a blog on it. After a long time experimenting, I have decided to write this blog in a table fashion(sounds odd, but easy to understand). Here you go.
What is an Exception?
An exception is an event that occurs during the execution of a program that disrupts the normal flow of instructions during the execution of a program.
What is an Error?
Errors are the mistakes or faults in the program that causes the program to behave unexpectedly.
Types of Exception
Exception: Most languages throw an exception at run-time except java. Java provides two types of exceptions. Let's see them.
Checked Exception: Checked exceptions are known to the compiler and must handle at compile time.
Unchecked Exception: These errors are not checked at runtime.
Types of Error
Compile Time Error/ Syntax Error: Common syntactical mistakes in the code.
Run Time Error: Run time errors that are caused by the environment in which the program is running.
Logical Error: Mistakes in the logical flow of the program.
Here comes the Point of Confusion :
Exception
Error(Run-Time)
Examples of Exception
Example of Errors
Summary
That's a wrap. Share your thoughts in the comment section. Connect with me on Twitter for more awesome content.
33