How to Handle Exception using Throws Keyword in Core Java

In this tutorial how to handle Exception using throws Keyword in Core Java  is shown.

Code:

ExceptionThrows.java

class ExceptionThrows
{
public static void main(String args[]) throws ClassNotFoundException
{
System.out.println(“main is called”);
c();
}

public static void a() throws ClassNotFoundException
{
System.out.println(“a is called”);
Class cls=Class.forName(“java.lang.Integer”);
System.out.println(cls.getName());
System.out.println(cls.isInterface());
}

public static void b() throws ClassNotFoundException
{
System.out.println(“b is called”);
a();
}

public static void c() throws ClassNotFoundException
{
System.out.println(“c is called”);
b();
}
}

Add a Comment

Your email address will not be published.