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

OVERLOAD&OVERRIDE

 
asin lin
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys
Pleas tell me....
How to distinguish the practical urage between [OVERLOAD] and [OVERRIDE]?
And in what way can they be applied to?
thanks a lot
 
Chengwei Lee
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think illustration by examples would be easier for you to understand:
Method overloading:

Method Overriding:
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Message overloading is having the same method name with different parameters:

method overriding happens when a subclass changes the behaviour of one of its superclasses by implementing the same method in a different way. For example:

This example shows that objects that are Mammals give birth to live young. However, Monotremata (which includes the platypus and the echidna), while they are mammals, lay eggs instead of giving birth to live young. Also, marsupials (kangaroos, opossums, koalas, etc.) give birth to live young but then put the young in a pouch.
An important difference to note is that overloaded methods are bound at compile-time, while overridden methods are determined at run-time.
 
Anderson leeak
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OverLoading means there will not less than one same method,but these method can have
different arguments for every method.
OverRiding just happened when a subclass entends its superclass by implementing the
same method in a different way. But how the OverRiding is happened in the run-time which
can be called late-binding.but the OverLoading is bound at complie time.
I want to apologize for my poor english,because i came from china.so english is not so good.
thansk
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thinkpad leeak,
Welcome to JavaRanch!
We do not have a lot of rules around here, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic