Exception Demo

class nulldemo1 {
	void disp() {
	}
}
public class ExceptionDemo1 {
	nulldemo1 d;
	void function1() {
		try {
			d.disp();
		} catch (NullPointerException e) {
			System.out.println("error1" + e);
		} catch (ArrayIndexOutOfBoundsException e) {
			System.out.println("error2" + e);
		} catch (Exception e) {
			System.out.println("error" + e);
		}
		System.out.println("this is after catch");
	}
	public static void main(String[] args) {
		ExceptionDemo1 obj = new ExceptionDemo1();
		try {
			obj.function1();
		} catch (Exception e) {
			System.out.println("in main method" + e);
		}
	}
}

Download

Exception Example in Java

Exception Example
Exception Propogation
User Defined Exception


Write your Comment

Name :
Email Id : [ We will not publish your email id ]
Your Comment : [ Maximum 200 chars ]
Enter Security code