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 Reg:Override and redefine 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 "Reg:Override and redefine" Watch "Reg:Override and redefine" New topic

Reg:Override and redefine

prema venkat

Joined: Sep 27, 2006
Posts: 14
hai all,
i cant understand the difference between override and redefine of a sstatic method.
we know static cant be override but we can redefine in subclass means what it mean?

for example:
class Animal
static void daStuff() //Line 1
class Dog extends Animal{
static void daStuff() //line2
public static void main(String arg[])
Animal[] a={new Animal(),newDog(),newAnimal());
for(int x=0;x<a.length;x++)


Here line 2 seems like an override of line 1 but in the defination of this program it seems like line2 is redefinition not override.(coz static)

Please clear by doubt that how the redefinition differs from override coz its having same modifier and return type as like override.

Thanks in advance
Chris Stann
Ranch Hand

Joined: Oct 10, 2006
Posts: 49
Page 98, Chapter 2 of our famous SCJP book explains it well, I think: "Polymorphic method invocations apply only to instance methods. You can always refer to an object with a more general reference variable type (a superclass or interface), but at runtime, the ONLY things that are dynamically selected based on the actual object (rather than the reference type) are instance methods. Not static methods. Not variables. Only overridden instance methods are dynamically invoked based on the real object's type."

prema venkat

Joined: Sep 27, 2006
Posts: 14
Thanks Chris.Now i am clear with this.
Guru dhaasan
Ranch Hand

Joined: Sep 13, 2006
Posts: 126

Hi Prema,

as you know, static is per class.

Overriding is the concept of polymorphism which can be applied to objects.

So the Animal class' doStuff belongs to that class only and Dog class' doStuff belongs to that class.

Even the object of Dog dont have a idea of the Animal class' doStuff method

Thats why its called redefinition

Hope you got the point


Thanks, Shiv
SCJP, OCE - JSP & Servlets Developer
prema venkat

Joined: Sep 27, 2006
Posts: 14
Yes Guru.I got the point.Thanks.
Don't get me started about those stupid light bulbs.
subject: Reg:Override and redefine
Similar Threads
Overriden VS Redefinition
what is the difference b/w overriding and redifining
What is diff between method redefinition and mehtod overriding?
K&B book doubt on page 147
Static method : Redefinition or an override ?