Error Vs Exception

Posted on 2012-09-17
Last Modified: 2012-09-18

Someone asked me the difference between the two. I got one point, please check whether it is fine or not and what are the other points that elaborates the difference between the two.

"An error is a condition which is not catched whereas an exception is a condition which can be catched."
Question by:KaranGupta
    LVL 9

    Assisted Solution

    You're correct.

    An exception is just that, something that is outside the parameters.

    Where as an error is a mistake, they can be syntax errors, logic errors, etc...

    An exception can occur because of an error, or it can be thrown intentionally.
    LVL 27

    Assisted Solution

    LVL 5

    Accepted Solution

    Simply, put

    an error is something which is wrong, either syntactically or logically or a wrong implementation of a requirement.

    For eg

    1. A syntax error is using == to assign a value to a paramete
    2. A logical error is to use subtraction in place of addition
    3. A wrong implementation error is that yields to wrong or unexpected results

    However, an exception is that 'condition' which occurs in a certain situation. For eg, simply put,

    X = y/a

    This code is prone to an exception in case a becomes 0. But only in case a becomes 0. Till the time, a is not 0, the code will work fine and yield expected results.

    I hope that is of some use.


    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
    By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
    Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
    Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now