Java actually enforces even stricter rules about signature compatibility in subclasses. It allows a subclass to be declared to throw a subset of the exceptions or to throw subclasses of the exceptions thrown by the superclass, but otherwise subclass and superclass must have identical method signatures. Methods rule . A subtype's specification for any method must be at least as strong as its supertype's specification. So, a subtype method can weaken the precondition and can strengthen the postcondition.
Properties rule .
The subtype must preserve all properties that can be proved about the supertype. Invariants that are guaranteed in the supertype must also be guaranteed by the subtype. Subtypes A subclass in Java does not have to be a true subtype. In order to be a subtype, the methods of the subclass must satisfy the superclass's specifications. However, this cannot be checked by the compiler, so it is possible to create a subclass that is not a subtype.