In the following example, the call FirstChildclass first; first.someMethod();
will do the same as SecondChildclass second; second.someMethod();
. Or am I wrong?
class Superclass {
public void someMethod() {
//do something
}
}
class FirstChildclass extends Superclass {
@Override
public void someMethod() {
super.someMethod();
}
public void someOtherMethod() {
//do something else
}
}
class SecondChildclass extends Superclass {
public void someOtherMethod() {
//do something else
}
}
Is there a reason why one will implement it like in FirstChildclass
? Because I have seen many implementations like in FistChildclass
and am wondering why anyone would do it.