I am reading the book The Java Programming Language. In the chapter which explains overriding method, it says:
Making an override method (in subclass) less accessible than it was in super class would violate the contract of the superclass …
The text as a whole is understandable. My only question is what is contract of the superclass? What does the contract mean for a Java class?
A contract in in a Java class is similar to a contract in the real world – In non-technical terms:
It’s an agreement that the class will expose certain methods, certain properties, and certain behaviors.
More technical, from here: (bold added by me)