The compiler will throw an exception during compilation, but it's not the same exception as the one thrown in bar(). The exception thrown in bar() (after you declare that the method throws a checked exception) will still only be thrown during runtime of your application.
UncheckedException, you mean?
Stephan van Hulst wrote:RuntimeException really is a misnomer. They should have called it CheckedException instead.
The theory is that the runtime Exception occurs entirely within the Java® runtime rather than at the interface between Java® and other code. An IOException occurs when you attempt to access the hard drive or network or keyboard, for example. That is why they called in runtime Exception. At least that it the theory; most people can find exceptions to that notion.
Exceptions do not occur at compile time. Period.
A compilation error is not an Exception.
thats what I was trying to confirm. Thank you.
Exceptions do not occur at compile time. Period. A compilation error is not an Exception.
Campbell Ritchie wrote:UncheckedException, you mean?