• Post Reply Bookmark Topic Watch Topic
  • New Topic

Overriding Vs. overloading  RSS feed

 
Nabila Mohammad
Ranch Hand
Posts: 664
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public void call (String n, int i) { }

public void call (int i, String n) { }


Is this overloading or Overriding?
 
Keith Nagle
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An overload.
The method that will be pushed onto the stack at runtime
will be determined at compile time by the
method arguments:

Is not the same as:

[ July 14, 2008: Message edited by: Keith Nagle ]
 
Milan Sutaria
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the condition for overriding is the signature of the 2 methods must be exactly same. So it is definitely not an override.
for overload, the methods must differ in their arguments. the 2 methods are differing in their arguments(though in a sill way of swapping their places) (String s,int i) is definitely not the same as (int i , String s)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!