Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

difference between redefinition and overriding

 
ansuman mohapatra
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want the difference between method redefinition and method overriding. Can som1 please explain with an example..
 
Sidharth Pallai
Ranch Hand
Posts: 134
Hibernate Java Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
ansuman mohapatra
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 95
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Denis Bogdanov
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Sidharth Pallai
Ranch Hand
Posts: 134
Hibernate Java Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic