About Me

My photo
santrampur, gujarat, India
i am a hunger of knowledge

Wednesday, December 29, 2010

polymorphism

In computer science, polymorphism is a programming language feature that allows values of different data types to be handled using a uniform interface. The concept of parametric polymorphism applies to both data types and functions. A function that can evaluate to or be applied to values of different types is known as a polymorphic function. A data type that can appear to be of a generalized type (e.g., a list with elements of arbitrary type) is designated polymorphic data type like the generalized type from which such specializations are made.

*      The calling of a variety of operations using the same interface.

*      For example, a sub class can refine the implementation of a method or property inherited from its super class.

*      The property or method is there by redefined even if the super class is used as the interface class.

*      Thus, the logical device class can define the variable status as a string and can return the values “on” or “off”.

*      The modern sub class of logical device can redefine status by returning “on” or “off” and “connected”.

*      If all logical devices are enumerated any logical device that happens to be a modem can return the value “connected” for the status property.

*      Polymorphism enables a single method to exhibit different behaviors when used with different objects.

*      Method overloading is one form of polymorphism which a lows us to have two or more method declaration.

Example of overloading
Public overloads function find data (by val, name as srn as Array list find data and return result end function
Can be overloaded as shown below

Public overloads function find data (by val age as integer)
As array list find data and return result end function
Overloading constructers:
                  A constructor performs various. Tasks those are not visible to you as the programmer even if you were no code for the constructer. These tasks are all associated with building a complex.

Example
Public overloads sub new ()
      Initialize object here
End sub
Public overloads sub new (by Val ID as integer)
      Use the ID value to initialize the object
End sub

No comments:

Post a Comment