I think answer 1 is fine.
The signature of a method is composed by its name and its parameter list (here DoubleValue(int a)). The compiler complains because it indeed sees two methods with the same signature.
Changing only the return value is not enough to overload a method. Changing its parameter list (with float in this case) would make the code compile.
Originally posted by Hina Mustafa:
hi,
There's a question from a mock exam..
Consider the following code and select the most appropriate statements.
Public class overL{
public int doubleValue(int a){}
public float doubleValue(int a){}
}
the correct answers given by the exam are
1-The code doesn't compile because the compiler sees two methods with the same signature.
2-The code can be made to compile by redefining the parameter for doubleVal() on line 7 to be "float a" instead of "int a".
I suspect that answer 1 is not correct instead of 'singnature' it should be 'parameter'.
Please someone assure me I'm right.
Thanx
Hina.