my dog learned polymorphism*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Overloading Signature Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Overloading Signature" Watch "Overloading Signature" New topic
Author

Overloading Signature

Divakar
Greenhorn

Joined: Mar 01, 2000
Posts: 25
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

Joined: Jan 31, 2000
Posts: 1467
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

Joined: Mar 09, 2000
Posts: 1
stupid question
does the method signature include the access modifier(public,private...)
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Jan 30, 2000
Posts: 3222
    
    5
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.


Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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
 
subject: Overloading Signature
 
Similar Threads
Signature question
Questions for you
Parent class -> Child class
question related to interfaces
Overriding and overloading