Skip to main content

Exception


Exception: An unwanted unexpected event that disturbs the normal flow of the program is called an exception.
Example:
SleepingException
TyrePunchuredException
FileNotFoundException…..etc
It is highly recommended to handle exceptions. The main objective of exception handling is graceful (normal) termination of the program.
What is the meaning of exception handling?
Exception handling doesn’t mean repairing an exception. We have to define an alternative way to continue the rest of the program normally this way of “defining alternative is nothing but exception handling”.
Example: Suppose our programming requirement is to read data from London file at runtime if London file is not available our program should not be terminated abnormally. We have to provide a local file to continue the rest of the program normally. This way of defining alternative is
nothing but exception handling.
Example:
      try
         {
                read data from london file
         }
       catch(FileNotFoundException e)
         {
                 use local file and continue rest of the program normally
           }
        .
        .
        .

Comments

Popular posts from this blog

Core Java

Content 1 - Language fundamental   Identifier Reserved words Data types Literals Arrays Types of variables Var arg method Main method Java coding standards 2 -  Declaration and Access Modifiers Java source file structure Class modifiers Member modifiers Interfaces 3 - Exception Handling Introduction Runtime stack mechanism Default exception handling in java Exception hierarchy Customized exception handling by try-catch  Control flow in try-catch Methods to print exception information Try with multiple catch blocks Finally Difference between final, finally, finalize Control flow in try-catch-finally Control flow in nested try-catch-finally Various possible combinations of try-catch-finally throw keyword throws keyword Exception handling keywords summary Various possible compile-time errors in exception handling Customized exceptions Top-10 exceptions  4 - String Concept of String Immutable String String Comparison String Conca