• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Overridding!!

 
divya sharma
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Please help me to understand over ridding concept.

Thanks
Divya
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read this. Should help you out!
 
divya sharma
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply!!!

If property of the method could be modified then what is overloading? As per my understanding Overloading is multiple methods with different parameters, but the methods do the same thing.
 
Anton Uwe
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Overloading: Multiple methods with different parameters, all methods have the same name, but they can do whatever they want.

example:
 
Madhusudan Banik
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Overriding means rewrite the inherited behaviors. It something�s like overwrite a file into our file system. When we a save a file name test.txt and the directory already contains a file with similar name then a message come to inform that. Anyway overriding comes into contact when a class extends another class. A class can overrides the inherited methods. Not all inherited method can be overridden. Static, final method cannot be overridden. Overriding introduce another complexity like which method implementation is bind to a method invocation. These things will be found on book.
 
divya sharma
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please explain me some think more as i an still confusted b/w overridding and over loading

thanks,
divya
 
Madhusudan Banik
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In overriding method signature(method name+parameter type) need to be same but in overloading method signature must be different. Think we need square root of double, long, float, int type, then what i we could do. define different method for each data type. like for double sqdouble(double d), for int, sqrint(int i), etc. If we do that it will creates some problem, such that user of the method must know that which version of the method square root we need to call. to remove such difficulties we use overloadding. we use the same func sqr(double d), sqr(int i), etc. More on found on book.
 
Damodara Reddy
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Overloading : Having multiple methods with different method signatures( parameters + return type) ,
In the case of overloading , method is called upon the matching of method signature, and this will be determined at the time of compilation(Early binding/compile time polymorphism).

Overriding : This comes with point of inheritance,
method name+ parameters + return type must be same as of the method in the super class which we want to override.

Overriding is done when you want to replace particular method's functionality in the subclass.
JVM determines which method to call at run time.( This is called as Late binding/ Run time polymorphism).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic