WAP that demostrates the use of throw keyword in exception handling. main() method will call a(), a() calls b(), b() calls c() and method c(), b() and a() will throw an exception. Implement this hierarchy

/* WAP that demostrates the use of throw keyword in exception handling. main() method will call a(), a() calls b(), b() calls c() and method c(), b() and a() will throw an exception. Implement this hierarchy.*/

import java.io.*;
class Tk
  {
   
                  void a() throws IOException
{
throw new IOException("error che bhai");
}

      void b() throws IOException
      {
           a();
         System.out.println("b che");
      }

      void c()
{
       try 
       { 
           b();
            System.out.println("c che");
     
        }
     
   catch(Exception  e)
      {
       System.out.println("joy hall su bhul" + e.getMessage());
     }


public static void main(String []args)
           {
             Tk  t1=new Tk();
                 t1.c();
             System.out.println("terminal");
         }
}

Comments

Popular posts from this blog

Write a java program to calculate gross salary & net salary taking the following data

WAP a program that illustrates interface inheritance. Create two interface p1 and p2 . create Interface p which extends p1 and p2 and then create interface p12 which extends p12. Each interface declare one constants and one method. Create class Q which implements p12 and define all the methods of interface which displays value of constants

WAP that create interface on that you declare one method interest(p,r,n) then create two class simple and compound that implements interest and find simple and compound interest.