Wednesday 20 July 2011

difference between overloading and overriding .{ excluding the simple parameter diifference}

when i say that explain that what is the difference between overloading and overriding than , all answer will point the same thing that ... changing a thing without changing its variable , its type , its name is overriding , and changing everything except it name is overloading .

now do you think that it is ok , or not . than i will say that you are correct in some meaning but you are wrong in basics . the main difference between overloading and overriding is related with binding , but why
because every thing in every language is related with some binding . so how overloading and overriding is different .

overriding is done or come in existance in the form of dynamic binding , but why , overriding is done in dynamic time ,i think methods can having same name ,same parameter ,same type .... if every thing is same ,than you can not differ it in compile time so overriding is performed in dynamic time .

and in overloading every thing is done in time of compile time now the question is why this is done in compile time , i think that every thing or one thing is differ than original one so overloading is performed in the compile time, because diffreentness can be easily searched in compile time .

now what is the meaning of compile time and run time .
------------- class  alpha {}

    alpha ob1 = new alpha ( );
    " alpha ob1 " is compile time means overloading is depend upon this thing or this type .
   " new alpha ( ); " is run time means overriding is depend upon this thing or this type .

means overriding is depend upon dynamic selection it does not depend upon reference type .

means if  " beta ob1 = new alpha ( ); "
here if beta have a method display ( ); and alpha have a method display ( ) , not different in signature;
than making or creating display between these two is very hard in compile time .
so it first goes to " new alpha (  )" and finds that original object is of alpha type and assign all properties of alpha now all things are depend upon you that now you want to reduce it or you want to make them as a constant .

in overloading , methods are different in signature  , easily caught in compile time so it is heavily depend upon , simple or static binding .

No comments: