Author | Topic: Overloading Signature |
Divakar greenhorn |
posted March 09, 2000 09:26 AM
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).
|
maha anna bartender |
posted March 09, 2000 10:40 AM
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 |
posted March 09, 2000 08:55 PM
stupid question does the method signature include the access modifier(public,private...)
|
Joe Java ranch hand |
posted March 09, 2000 09:34 PM
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 sheriff |
posted March 10, 2000 01:20 PM
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.
|
Umesh ranch hand |
posted March 10, 2000 04:17 PM
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.
|
| | |