This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Dear Praveen, Over-riding: This is done when you provide a different implementation of a method (belonging to a super-class) in your class. This over-riding method should have the same signature as your superclass method. And along with that the access modifier that you specify for the over-riding method should have a scope equal to OR higher than the superclass method. Hope I am not confusing matters here. As you can see from the example you provided, the method in your subclass had a scope smaller than the superclass, so the compiler throws an error. Over-loading: This is done when the method signature is the same but either of the following conditions should be met:
the number of parameters is different
the order of the parameters are different
the type of parameters are different
I have a feeling I have written a lot of information that may be incorrect. So just wait until an expert comes in and verifies the information. I just wrote my understanding of Overloading/Over-riding methods. [ April 20, 2006: Message edited by: Shyam Murarka ]