Current location - Quotes Website - Signature design - What are the grammatical rules of rewriting in java?
What are the grammatical rules of rewriting in java?
The overridden method is the same as the parent method signature (method name and parameter list);

The scope of the method access modifier overridden by a subclass cannot be lower than that of the parent class;

You cannot override the private methods of the parent class;

Static modification methods cannot be overridden.

Return value type:

If the return value types of methods in the parent class are eight basic types, String and void, they must be the same;

If it is another reference type, the subclass is rewritten in the method with the same return type or the return type of its parent class.

With regard to exceptions, the exception range of the subclass override method is smaller than that of the parent class method or there is no exception.