This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes What is diff between method redefinition and mehtod overriding? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "What is diff between method redefinition and mehtod overriding?" Watch "What is diff between method redefinition and mehtod overriding?" New topic
Author

What is diff between method redefinition and mehtod overriding?

Arpit Gadle
Ranch Hand

Joined: Dec 16, 2008
Posts: 69

We cannot override a static method but we can redefine it. But looking at the code below it seems that we are overriding a static method? So wat is the diff between method redefinition and method overriding?




[HENRY: Added Code Tags]
[ December 16, 2008: Message edited by: Henry Wong ]
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18545
    
  40



You code example is actually a good demo of this. Notice that it is calling the Animal class' method, even for the Dog class. The reason is... the reference (array element) is an animal, hence, it calls the animal method. If the method had been overriden, then the Dog object would have called the Dog's version of the method (overridden method) instead.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Harvinder Thakur
Ranch Hand

Joined: Jun 10, 2008
Posts: 231
OverridingVsHiding
This link will help you.


thanks
Harvinder
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is diff between method redefinition and mehtod overriding?
 
Similar Threads
Overriden VS Redefinition
Static Method - Redefine/ not Overriding
K&B book doubt on page 147
Static method : Redefinition or an override ?
Difference between redefinition and overridding