+ 3

What the difference between dynamic and static polymorphism?

21st Apr 2017, 2:36 PM
Nikita Galchenko
Nikita Galchenko - avatar
4 ответов
+ 8
In static binding, its like the function and the data on which that function is to be performed is known already at compile time and so are bound at compile time. Where as in dynamic binding the data and functions are not known until the run time, I mean we may have the data and function, but we do not know which function is to be performed on which data, it is only during the execution time that the functions are performed on the data and hence are bound at run time.
21st Apr 2017, 3:32 PM
Saumya
Saumya - avatar
+ 4
Static polymorphism involves early binding or compile time binding whereas dynamic polymorphism uses late binding or run time binding. The term static polymorphism is associated with overloaded methods because it gives the impression that a single named method will accept a number of different argument types. The System.out.println() method is an example that may take String or Object references, boolean and other primitive types as an argument. In fact, each overloaded method is separate and the compiler can see the difference between them. In this case, the argument types are fixed at compile time and are considered static. This has nothing to do with the Java keyword static. Dynamic polymorphism is where a class overrides a superclass method or implements an interface. For example, any class may override the Object.toString() method and provide its own implementation, and this is known at compile time. However, for a simple Java program that initiates a series of objects and calls their toString() method, the compiler does not consider the object references differently. Any differences in the objects' toString() implementations are only seen at runtime, so they are considered dynamic.
21st Apr 2017, 3:35 PM
Sirajuddaula AraFat
Sirajuddaula AraFat - avatar
+ 3
thanks
21st Apr 2017, 3:37 PM
Nikita Galchenko
Nikita Galchenko - avatar
0
ahaha.. (not funny). i mean what happend at compile time and etc.. i have found an article in the Internet.. but there are not enough information..
21st Apr 2017, 2:56 PM
Nikita Galchenko
Nikita Galchenko - avatar