This week's book giveaway is in the Security forum.
We're giving away four copies of Securing DevOps and have Julien Vehent on-line!
See this thread for details.
Win a copy of Securing DevOps this week in the Security forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Overriding and redefining  RSS feed

 
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
 
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.
 
(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.
 
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?

 
Hey, sticks and stones baby. And maybe a wee mention of my stuff:
Thread Boost - a very different sort of advertising
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!