Ideally you should have debugged to checkthe flow, but, still. When in the main method you say then the control gets to the s1() method of class Plane. Now s1 in turn calls s2() which calls s3(). But, as both S2 and s3 don't do exception handling and just throw the exception the exception is finally handled in the catch block of method s1()
Now, since String s is a member variable and is initially declared as "-". Thus in the catch block it becomes
1. The main() method is the entry point. 2. The main() method creates an object of type Plane. 3. Immediately, the method s1() is called. 4. s1() calls s2() within a try block to catch any exceptions that might be thrown. 5. s2() calls s3(). 6. s3() throws an exception. Control is thrown back to s2(). 7. In s2(), control goes back to the first call of s3(). 8. s2() doesn't catch the exception, it immediately stops executing and the exception is thrown back to s1(). 9. The exception is caught in s1() in the "catch" block. Here, the exception is handled by appending the string "c" to the String variable s which has a value of "-", thus s is assigned a value of "-c". 10. s1() has caught the exception so it does not throw it. 11. s1() terminates normally and control goes back to main() at the point that s1() was called. 12. The next line in main() is executed and the value of the variable s, "-c" is output.
If you don't understand, I can make an easier example to teach you how exceptions are thrown and are caught. [ March 05, 2008: Message edited by: Kaydell Leavitt ]