class A{ public void show() throws ClassNotFoundException { System.out.println("In the show method"); Class.forName("Calculator"); //Thi method loads the class in the memory at the runtime //but because the class doesn't exist, the compiler will throw exception at compile time //which we are gonna handle in the main() method using try catch } } public class Throws_Demo{ public static void main(String[] args){ A obj=new A(); try{ obj.show(); //Calling the method which will throw the exception } catch(ClassNotFoundException e) { System.out.println(e); } } }