Stefan Evans wrote:If I want to call myInterface.doSomething then I have to catch an exception. Right?
Yes, you have to.
The implementing method can declare to throw an
Exception, any subtype(s) of
Exception, or nothing at all. But if the method is called through the interface, the caller must handle
Exception, since it can't be known which implementation will be used and which exceptions it declares to throw.
Of course, if someone called the implementing method directly (that is,
MyImplementation.doSomething() instead of
MyInterface.doSomething()), they'd have to handle only those (checked) exceptions declared by the implementation. But if someone wanted to do that, why bother declaring the interface at all?