How to override child Exception from parent Exception class?

Here we are override child Exception from parent Exception class.there are two class one is child and other is parent class.in child Exception class is more preferable than parent class Exception class.

				
					import java.io.IOException;

class Main {
	public void test() throws IOException {
		System.out.println("super");
	}
}

public class ExceptionOverride extends Main {
	public void test() throws ArithmeticException {
		System.out.println("kamal");
	}

	public static void main(String[] args) {
		ExceptionOverride a = new ExceptionOverride();
		a.test();
	}
}
				
			

Output :-
kamal

Leave a Comment

Your email address will not be published. Required fields are marked *