File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Overloading Signature

 
Divakar
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following statements are true?





a) Overridden methods have the same method name and signature

b) Overloaded methods have the same method name and signature

c) Overridden methods have the same method name and different signature

d) Overloaded methods have the same method name and different signature
My answers (a) and (d).
Can overloaded methods have same signatures??
Signature of overloaded method will include its name argument type and not its return type.Overloaded method means same method name and differrent arguments. If you change the argument the signature will also change ,am I right??
 
maha anna
Ranch Hand
Posts: 1467
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you are right. And 1 more thing. Even in JLS this is not specified clearly. The order of the arguments is also VERY IMPORTANT. For example
void m1(int i,float f) {}
void m1(float f,int i) {}
These 2 methods are NOT OVERRIDDEN. Instead they are OVERLOADED. Also note that when invoking
m1(10,10f); //Ok
m1(10f,10); //Ok
m1(10,10); //Compiler will shout!!! It is ambiguous.
regds
maha anna

[This message has been edited by maha anna (edited March 09, 2000).]
 
jala
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
stupid question
does the method signature include the access modifier(public,private...)
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
No, thats not a stupid question at all, but a stupid answer is nope! Whats more i'm also too lazy to elaborate.
 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, the signature does not include the access modifiers nor the return type. Only the name of the method, and the types, number and order of the arguments.
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
Can anybody give some tips on In which situation we may need to go for OVERRIDING or OVERLOADING considering I am new to OOP.
thanx in advance.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic