Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Overriding and redefining

 
Dheepan Thangavelu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
What is the Diff between Overriding and redefining a method.

Rgds,
Dheepan
 
Ishan Bhatt
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No difference.
Overriding is redefining a method previously implemented in a parent class to change its behavior.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think "redefine" has a specific meaning in OO circles. If you mean override it will be clearer to say override.
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or were you thinking of static methods? Static methods can't be overridden, but
they can be hidden:

Here, f is an example of overriding, g is an example of hiding,
and h and k are syntax errors. Quiz: what output does this produce?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic