Superclass of all exception classes

The java.lang.Throwable is the superclass of all exception classes in java.

Hierarchy Exception

Hierarchy Error


public class Main {
    public static void main(String[] args) {
       int num1= 30, num2 = 0; 
		// Try to divide by zero 
		try { 
			int result = num1 / num2; 
		catch (Throwable e) { 
		    System.out.println("Exceptionn class: " + e.getClass().getName());


Exceptionn class: java.lang.ArithmeticException
java.lang.ArithmeticException: / by zero
        at Main.main(

Java interview questions on Exception Handling

Content Protection by
Please Share