1.

What do you understand by polymorphism can you present a code?

Answer»

Polymorphism depicts the ability where a method can have various behaviors entirely depending upon the object type where it is called or its type for which is passed as a parameter. for EXAMPLE, if a user has to define their own class "MyInteger" and a method "ADD" for the same following CODE has to be TYPED to bring it in functioning.Example

Basically to add certain integer ALONG with another number we would follow through-

MyInteger int1 = new MyInteger(5);
MyInteger int2 = new MyInteger(7);
MyFloat float1 = new MyFloat(3.14);
MyDouble doub1 = new MyDouble(2.71);
print(int1.add(int2));
print(int1.add(float1));
print(int1.add(doub1));



Discussion

No Comment Found