Suppose I have an inheritance chain where every class extends its superclass by adding a new field and I want every class of that chain to override the toString()
method like so:
public String toString()
{
return super.toString() + "[newfield=" + newfield + "]";
}
If I use an abstract base class then when a class of the inheritance chain becomes concrete by implementing the abstract method all the subclasses from that point on become concrete as well by inheriting the already implemented method.
Is there a way in Java to force every class to override (reimplement) the abstract method even though it has already been implemented higher in the inheritance chain?