Java All Exceptions Tutorial


1. Exceptions – Meaning
2. Runtime Error – Groups – Exception causes
3. Exception Handling: try – catch
4. try – catch – finally
5. Hierarchy of Exceptions – Checked/Unchecked Exceptions
6. Throwing with "throws" – Alternative to try-catch
7. Creating User-defined Exceptions – throw Keyword
8. getMessage() & printStackTrace()
9. Try – Finally (without Catch)
10. Rules of Exceptions in Method Overriding

Some commonly occurring exceptions, elaborately discussed.

NumberFormatException NoSuchMethodError
ClassNotFoundException IllegalArgumentException
MalformedURLException UnknownHostException
IllegalThreadStateException ClassCastException
RuntimeException IndexOutOfBoundsException
FileNotFoundException & IOException InterruptedException

7 thoughts on “Java All Exceptions Tutorial”

  1. public void run(){
    for(int i=1;i<5;i++){
    try{Thread.sleep(500);}catch(InterruptedException e){System.out.println(e);}
    System.out.println(i);
    }
    }
    public static void main(String args[]){
    TestCallRun2 t1=new TestCallRun2();
    TestCallRun2 t2=new TestCallRun2();
    t1.run();

    t1.start();

    t2.start();
    }
    }
    in this program pl explain the difference between t1.start();and t1.run();?
    what they actually does?

    1. Every thread has a life cycle (4 states exist) maintained by JVM like getting into dead state when the job of the thread is over. If you call run() method, the life cycle is not taken care of. There may not be difference in output, but many internal things do not happen what a thread is eligible.

Leave a Comment

Your email address will not be published.