17 Oct 2014
Method Overriding in Java
A subclass inherits all public and protected methods from its super class. You can modify the superclass methods in subclass with the same method signature as defined in superclass. Some it is very important to modify superclass method in subclass to change or customize the implementation of superclass method.
The following class Card
Note :
- An instance method is overriden if it is accessible.
- Private methods can’t be overriden because they are not accessible from their own class
- If a method defined in subclass is private in its superclass then both are totally different methods
- A static method can be inherited, but can’t be overriden
- Redefining a superclass static method in its subclass, in result the method defined in superclass is hidden
No Responses