class ExceptionOne extends Exception
{
    public ExceptionOne ( String s )
    { super(s); }
} 

class ExceptionTwo extends ExceptionOne
{
    public ExceptionTwo ( String s )
    { super(s); }
}

class ExceptionThree extends Exception
{
    public ExceptionThree ( String s )
    { super (s); }

}


public class Exam2
{
    public static void main( String []args )
    {
	while ( 0 < 1 ) {
	    try {
		System.out.println( "Value of bouncer: " + bouncer( 0 ) );
	    } catch (ExceptionThree e)
		{ System.exit(0);}
	}
    }


    public static int bouncer( int i) throws ExceptionThree
    {
	try {
	    if ( i < 1 )
		return bouncer (++i);
	    else
		tosser ( ++i );
	} catch ( ExceptionOne e) {
	    System.out.println( "caught Exception One " + i);
	    bouncer(++i);
	} catch ( ExceptionThree e ) {
	    System.out.println( "caught Exception Three " + i);
	    throw e;
	} 
	/* This is the bit that would have cause a compile problem, The problem is the code is unreacable because ExceptionTwo is an subclass of ExcpetionOne
	  catch ( ExceptionTwo e ) {
	    System.out.println( "caught Exception Two " + i);
	    return 7;
	}
	*/
	return 5;
    }

    private static int tosser( int i ) throws ExceptionThree, ExceptionOne, ExceptionTwo
    {
	if ( i > 3 )
	    throw new ExceptionThree("3");
	if ( i > 2 )
	    throw new ExceptionTwo("2");
	else
	    throw new ExceptionOne("1");
    }
}









