answersLogoWhite

Top Answer
User Avatar
Wiki User
Answered 2008-03-28 04:39:22

Short answer:

They are the same.

Long Answer, (and yet less revealing):

Polymorphism is simply the ability to have many different methods (Or functions, for those who are used to C-Type programs) to have the same name, but act differently depending on the type of parameters that were passed to the function.

So for example, we may have a method called punch, which accepts no parameters at all, and returns an integer:

public int punch()

{

return 3;

}

We could also have a method named punch that accepts a String and returns a boolean.

public boolean punch(String poorGuyGettingPunched)

{

if(poorGuyGettingPunched.equals("joe"))

{

System.out.println("sorry Joe");

return true;

}

else

return false;

}

That is called polymorphism... And strangely enough, it is also called overloading.

Do not confuse this with overriding, which replaces a function or method with a new one, or rather, hides the old method and replaces it with a new one.

001
๐Ÿ™
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
๐Ÿ˜‚
0
User Avatar

Your Answer

Related Questions


Runtime prolymorphism means overriding compiletile polymorphism means overloading


Operator overloading simply means to provide a new implementation for an existing operator. Polymorphism is a function of inheritance whereby it is not necessary to know the runtime type of an object so long as you know the generic type. The virtual table ensures you gain specific behaviour by calling the generic type's virtual methods.



Function overloading is multiple definition with different signatures(the parameters should be different) for the same function. The parameter list have to be different in each definition. The compiler will not accept if the return type alone is changed. Operator overloading is defining a function for a particular operator. The operator loading function can not be overloaded through function overloading.


Static polymorphism:memory allocated at compile time is called as static allocation.java resolves calls to overloading methods at compile time is called as Static polymorphism.Dynamic polymorphism:memory allocated at run time is called as dynamic allocationjava resolves calls to overloading methods at run time is called as Dynamic polymorphism or Dynamic binding or Dynamic dispatch.This principle is used to create reference variable.


really there is no difference between constructor overloading and metho overloading


While overloading operators using member function it takes only one arguments(other pass implicitly)... but in case of friend fuction two parameters are required..


Function overloading refers to using the same function name in the same scope with multiple versions depending on the parameters provided. Operator overloading is a specialized version of function overloading, and refers specifically to using operators instead of function names. These are usually designated with the keyword "operator". Function overloading: void doSomething(int arg1); void doSomething(int arg1, int arg2); Operator overloading: obj& operator +(obj arg1, obj arg2);


wrapping up of data and function into a single unit is called encapsulation where polymorphism is the ability to take more than one form


In static polymorphism is exhibited at compilation time, where as dynamic exhibited at runtime...


The dictionary definition of polymorphism refers to a principle in biology in which an organism or species can have many different forms or stages. This principle can also be applied to object-oriented programming and languages like the Java language. Subclasses of a class can define their own unique behaviors and yet share some of the same functionality of the parent class.Overriding and Overloading are two techiques to achive polymorphism in Java.Method overloading: When a method in a class having the same method name with different arguments is said to be method overloading. Method overriding : When a method in a class having the same method name with same arguments is said to be method overriding.


overriding means you're changing an already existing method. overloading means you're using the same method name, but you use different parameters in each one.


Static polymorphism is used the concept of early binding or we can say compile time binding where as dynamic polymorphism used the concept of late binding or run time binding.


The main difference is that: neither of them are related to one another. They have nothing similar between them and are totally different. The only point here is that they are both used in Java which can be stated as a similarity. Inheritance is the feature wherein functionality from one class is available for another class. Polymorphism refers to the feature wherein the same entity exists as multiple items. Ex: method overriding, method overloading etc.


difference between function and objectives?


Actually, overloading and polymorphism are two different things. Overloading is when two different functions of the same name but of different parameter types co-exist. The compiler determines which to call by looking at the match between parameter types. An example might be a sin function taking a parameter of type float versus an overloaded version taking a parameter of type long double. In the first case, only a few terms of the taylor's series is needed for reasonable precision; in the second case, you need more than that. Polymorphism, on the other hand, is when the class type of the function is known only by virtue of a pointer to a class of that class, typically a pointer that is declared to hold a pointer to the base class but, at run-time, assigned to hold a pointer to one or the other of two derived child classes. An example might be an area function that computes the area of a shape, that might be derived to be a circle, a square, an ellipse, etc.


Ploymorphism: It is the Object Oriented concept in which a single Object or function or variable is used in different forms. Overloading: polymorphism in which the same function name is used for different implementations with different parameter list or different types of parameters. Eg: To find the sum of integers, floats, double int sum(int, int); float sum(float, float); double sum(float, float); Note: if the retrun type is different the function is not overloaded but its a compilation error. Overriding: if a base class function is given a definitation in the derived class then this is called function overriding. Eg: class Base { int print() { System.out.println("Hello"); } } class Derived extends Base { int print() // overrides the function print in base class { System.out.println("Hi"); } } Note: in function overriding the drived class function's return type and the parameters should be the same as the base class function.


What is the difference between malloc() and calloc()?


fundamental difference between a polynomial function and an exponential function?


Inheritance is the object oriented feature by which the functionality and features of one class are made available to another class without having to copy paste the code. Polymorphism is the object oriented feature by which multiple methods of a class can coexist with minor differences. Ex: method overloading.


Inheritance and Polymorphism are two totally different things. The only relation between the two is that they are both Object Oriented concepts used in Java. Please check the Related Links to read in detail about Inheritance and Polymorphism and once you do, you will realize that they are both totally different.


The normal way a function works is that whenever your code encounters a call to the function, it jumps to the body of the function code. An inline function tells the compiler that it should actually copy over the code from a function body into all places where that function is called. In some cases this can cause a dramatic reduction in run time, but in others it causes nothing more than increasing the size of the produced executable. Function overloading refers to the ability to have multiple functions with the same name, but different parameter types.


Overloading and overriding do similar things but they are distinct. When you override a function, you are providing a new implementation of a function that was inherited from a base class. The signature of an override must be covariant with the base class signature. Overloading means to create several functions with the same name within the same namespace but with different signatures.


what is the difference between function and relation?


The only similarity is that both constructor and function overloads are distinguished by their signature -- the number and type of their arguments. Functions differ in that they also have a return type, which is also part of the signature, whereas constructors have no return type, not even void.



Copyright ยฉ 2021 Multiply Media, LLC. All Rights Reserved. The material on this site can not be reproduced, distributed, transmitted, cached or otherwise used, except with prior written permission of Multiply.