To address possible duplicates: I know what an interface is. I know how to implement them and all of that. I know what polymorphism is which allows the replacing of an object with a subtype. I know what abstract methods are, and I am not asking what any of these things are. Rather, I am asking what the point is for the inability to do what is so in the following question. Now to the question:
I have an interface. Let us call it Foo. It has the following abstract method:
public boolean isNumeric(Object o);
I also have a class Bar which implements Foo. It has the isNumeric method implemented like so:
public boolean isNumeric(DataPoint dp){
//some stuff
return true;
}
How come I cannot polymorph an abstract parameter? What is the point of the implementation of I can't be more specific?... Is that not part of the necessity of polymorphism. The allowance of going "down" a class and being able to be more specific to a particular case... it seems as though I cannot go backwards either; declare the parameter in the interface as a DataPoint and implement it as a Object.
Why can I not do so? Do I really have to cast it and then say in the Doc? "It has to be a DataPoint" bla bla bla? I can't just force it to be a data point in this case, and in another implementation be something else? If I have to cast I would have to handle the class cast exception and also counter the doc that defines the parameter which an explanation that says do not use "this parameter"... if that makes sense. It seems more work than the whole point of object oriented programming...
-Thanks
PS the questions are boldified.