rules for overriding


Rule #1: Only inherited methods can be overridden.

Rule #2: Final and static methods cannot be overridden.

Rule #3: The overriding method must have same argument list

Rule #4: The overriding method must have same return type (or subtype).

Rule #5: The overriding method must not have more restrictive access modifier.

Rule #6: The overriding method must not throw new or broader checked exceptions.

Rule #7: Use the super keyword to invoke the overridden method from a subclass

Rule #8: Constructors cannot be overridden.

Rule #10: A static method in a subclass may hide another static one in a superclass, and that’s called hiding.

Rule #11: The synchronized modifier has no effect on the rules of overriding.

Rule #12: The strictfp modifier has no effect on the rules of overriding.

Comments

Popular posts from this blog

தட்டு வண்டியில் காளிக்கோயில் - சிறுகதை

பிரேமாவின் பெண் குழந்தை

தீபம் பிளக்ஸ்