Sonir, for the benefit of you and other ranchers, start using the [ CODE ] and [ / CODE ] tags. Before posting code, press the CODE button that you can see next to the emoticons, and then place your those two tags. Posting a question and asking "why???", doesn't make any sense. You wont learn anything by it. Write your explanation, and what you think is the answer. If you don't agree with the answer given in the book, you tell us "why?" you don't agree. This would lead to much useful discussion., and you will find more people participating. And for now, I'm not telling you "why?" untill you give your explanation!!!
After running the program it prints : "m1Starts","1", and "4" in that order Why?Need explainations.
Hi sohir, initially m1() is called and "m1starts" is printed . Then the Exception is thrown. control comes to catch block that catches IndexOutOfBoundsException and "1" is printed. Now NullPointerException is thrown which is not handled in the catch block Remember that catch (NullPointerException e) block is related to try block and not to exception thrown in previous catch. Therefore method teminates abnormally (before that finally is always executed so "4" is printed) control goes back to caller ie. main. Therefore the o/p. HIH Rashmi