Originally posted by Kitty Dayal: What will happen to exceptions raised in catch block. Will it be executed or not.
They will be thrown. But because you are out of the try block by now, they won't be caught (unless there is another try block around the whole thing).
Why will it not print 2.
Because there is no NullPointerException thrown inside the try block.
Should checked exception only be thrown from try block?
No, but any checked exceptions that you don't catch must be declared in the method's throws clause. The main() method does not have a throws clause and therefore there cannot be any uncaught checked exceptions.
Also an exception thrown in finally block: "MUST" be in a try-catch/finally block(even if it is an runtime). Is this true ?
Probably not, although I don't really understand what you're trying to say but it looks wrong. The code you list does compile, but you declare a MyException which isn't being used so I guess the code you tried has problems with non-runtime exceptions which are neither being caught nor listed in a throws clause.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd