Thursday, 8 March 2012

Method overriding in Java

•In inheritance, when a method in both superclass and the subclass are having the signature, then the method in subclass overrides the method in superclass.
•This process of hiding the method in the superclass by the method in the subclass is called overriding.
•Method signature is the collection of return type, method name and the number and types of parameters of the method.
•So, the signature of the methods in both the superclass and subclass must be same for overriding to take place.


 

No comments:

Post a Comment