• Post Reply Bookmark Topic Watch Topic
  • New Topic

Method Overloadding  RSS feed

 
Amar Deep Singh Chaudhary
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the following example either method overloading or overriding ?
public int A(){}
public String A(){}
 
Pranav Pal
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If arguments to both the functions are same (in this case none) then it is clearly not overloading, because overloading doesn't depend on return types.

Since it is not possible to have both methods in the same class(which is a compile-time error), I am assuming that one is in superclass and other is in subclass.

And even if that is the case, this is a compile-time error:
A() in subclass cannot override A() in superclass;attempting to use incompatible return types
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!