jQuery in Action, 2nd edition*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes difference between redefinition and overriding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "difference between redefinition and overriding" Watch "difference between redefinition and overriding" New topic
Author

difference between redefinition and overriding

ansuman mohapatra
Greenhorn

Joined: Mar 04, 2008
Posts: 27
Hi,

I want the difference between method redefinition and method overriding. Can som1 please explain with an example..


Cleared SCJP.....
Sidharth Pallai
Ranch Hand

Joined: Apr 21, 2008
Posts: 134

Hi Ansuman,

Overidding is very specific to the context of Redifining which is a general phenomena.In java redifining can refer to Overloading or Overriding.In both cases we redifine a method but achieve different different purposes.Overidding is more than redifining,if we stress on OOPS.
It relates to dynamic polymorphism or dynamic dispatch or Early/Late/Static/Dynamic Bindings.Redifinition serves no objective in OOPS,its just a general perspective to the understanding of a particular construct.


Thanks & Regards
Sidharth Pallai
ansuman mohapatra
Greenhorn

Joined: Mar 04, 2008
Posts: 27
hey thanks 4 writin in...

but the doubt I have is in static methods overriding is not allowed, rather they allow method redifinition !!...That I didnt understand.

If method redefining refers to overloading or overriding then whats the difference of "Static Methods can't be overriden but can be redefined".
Shikhar Madhok
Ranch Hand

Joined: Dec 18, 2006
Posts: 95
this discussion may help.

I think I saw something similar discussed in ht e FAQ section will provide the link if i can find it.

HTH
Shikhar


He who asks a question is a fool for five minutes; he who does not ask a question remains a fool forever - Chinese proverb
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

That means the static methods can't be called in the context of overriding as overriding generally done with the specific version of method being invoked based on the *actual object* created at runtime.

As such the static methods are bound to the class and NOT the instances, this does not qualify for the aforementioned rule. That's why they say the static methods are NOT overridden but redefined.

You can try with a small example program for the same.
[ July 11, 2008: Message edited by: Raghavan Muthu ]

Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Denis Bogdanov
Greenhorn

Joined: Jul 10, 2008
Posts: 8
Sidharth Pallai
Ranch Hand

Joined: Apr 21, 2008
Posts: 134

Originally posted by ansuman mohapatra:
hey thanks 4 writin in...

but the doubt I have is in static methods overriding is not allowed, rather they allow method redifinition !!...That I didnt understand.

If method redefining refers to overloading or overriding then whats the difference of "Static Methods can't be overriden but can be redefined".


Its very basic to say "Static Methods can't be overriden but can be redefined". I would say that "Static method can be overidden !!,but they cant be overriden to be non-static" ie Static methods doesn't adhere to Dynamic Polymorphism or Dispatch.
Take this example :


If a.meth1() calls Super class method then i dont think static method respond to dynamic dispatch calls, unlike a.meth2() which does.

Apart form saying redifining static method i would consider saying it as Hidding Static methods, because static methods are hidden not overriden.
In this case Hidding/Redifining differs a lot with Overriding.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: difference between redefinition and overriding