+ 1
What is polymorphism?
How is it used and on which context is it used?
3 Respostas
0
simple
make multi functions with same name and different input values.
like:
bool compare(int a,int b){
return (a==b)?true:false;
}
bool compare(double a,double b){
return (Math.Round (a)==Math.Round (b))?true:false;
}
bool compare(string a,string b){
return (a.length==b.length)?true:false;
}
0
It means that you can use the interface as type and initialize it with an object of a class that implements that interface:
List<String> foo = new Arraylist<String>() ;
List<String> foo = new LinkedList<String>() ;
Simple: the right side decides the actual object type..
- 1
This is my description: Polymorphism means that one method and many difeirent implementation. For example: creating sound is a method, and the following are implementaitons: pig - grunts, duck - quack, cow - moos.