본문 바로가기

IT

sub2.java

public class sub2

{       

    public static void main(String[] args)

    {   

        try

        {       

//         throw new Exception();  

        throw new ExceptionA();  

//         throw new ExceptionB();  

//         throw new ExceptionC();  

         }

        catch(ExceptionC e)

        {   

            System.out.println("Caught Exception");   

            e.printStackTrace(System.out);           

        }

        catch(ExceptionB e)

        {   

            System.out.println("Caught Exception");   

            e.printStackTrace(System.out);           

        }

        catch(ExceptionA e)

        {   

            System.out.println("Caught Exception");   

            e.printStackTrace(System.out);           

        }

        catch(Exception e)

        {   

            System.out.println("Caught Exception");   

            e.printStackTrace(System.out);           

        }

    }

}



class ExceptionA extends Exception

{   

public ExceptionA(){

super();

}

public ExceptionA(String msg){

super(msg);

}

}   

   

class ExceptionB extends ExceptionA

{   

public ExceptionB(){

super();

}

public ExceptionB(String msg){

super(msg);

}

}   

   

class ExceptionC extends ExceptionB 

{   

public ExceptionC(){

super();

}

public ExceptionC(String msg){

super(msg);

}

}   

   



'IT' 카테고리의 다른 글

data structure source code  (0) 2014.06.02
sub1.java  (0) 2014.05.17
sub1.java  (0) 2014.05.17
sub2.java  (0) 2014.05.17
test3 .java  (0) 2014.05.17