Suppose we have this problem
public class Father{
public void method1(){...}
}
public class Child1 extends Father{
public void method1() throws Exce
Propagate the required exception to the Father.. to me this is against encapsulation, inheritance and general OOP ( the father potentially throw and exception that will never happen )
Au contraire: This is good OO. Image the caller side:
Father f = factory.getSomeImplementation();
f.method1();
// user has no chance to see the `Exception` of Child coming...
The factory can return an instance of Father or Child or something completely different like Brother. But the contract of method1 must be the same in all cases. And this contract includes checked exceptions. This is the Liskov substitution principle, one of the basic rules of OO.
So if the exception is part of the business contract of method1 it must be declared at the root. If it is not (e.g. a simple argument check) then a RuntimeException is the route to go anyways (i.e. even without inheritance).