Take a look at this code:
public interface Foo { public void bar() throws Exception; } public class FooImpl implements Foo { public void bar() { } public static void main(String args[]) { Foo foo = new FooImpl(); foo.bar(); } Why would I get an "unhandled exception type" compilation error, whereas if I changed
Foo foo = new FooImpl(); to
FooImpl foo = new FooImpl(); I wouldn't get any error?
From my understanding, public methods use dynamic binding, so shouldn't the original code call FooImpl 's bar() method as well?