Saturday 14 January 2012

how overloading and overriding is performed

hello everyone after a long time i am writing a post , i think it is very important to understand that how overriding is performed .

OVERRIDING ::

over-riding means , you are hiding something if you talk or want to understand in my language , but the previous thing which i said that hiding is not totally hided it maintains its status and state .





now this image is the perfect example for overriding . 
 


for this if you ever use or deal with java runtime environment than i think it is easy for you to understand , so when ever a call is created at that time a frame is created , and inside that frame the information is added , now what is that information .


so this information is passed in "this" and added to first position at the stack now our caller can easily find the method , i think it is easy but the problem arises when display does not occur in the sub_class ,



now another problem arises :: this problem looks like ...





how main_class ob = new sub_class ( ) ; will performed .



OVERLOADING ::

now we have to deal with overloading , before i explain you every thing please take a suggestion of mine that , when ever in your life you are dealing with overriding or with overloading than please use a stack of each and ever class inside of your mind , and i think any problem related with related with overloading and overriding can be solved easily .

now i am saying that you have to deal with "stacks" create a stack for each and every class and than solve your problem . take a example ::


now what ever code you write , it is handled easily by the stack , now how handling is performed .


so when ever you find problem like this , it is confusing for new people because it is too much same as overriding , but now my point come what i want to explain . because i never think that a definition of some point can play a important role or game in a real field .





so overriding means  :: same signature .
and overloading means :: different signature .


 and same signature is differentiated at run time because at compile time you can not differentiate so thats why you can create two same methods in a same scope and overloading deals with different signature and thats why the differentiated at the compile time so .

OVERLOADING == EXACT MATCH .
OVERRIDING == RUN TIME MATCH MAY OR MAY NOT EXACT .















No comments: