• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Polymorphism,Overloading, Overriding

 
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is Polymorphism, Overloading and Overriding?
What is difference between Overloading and Overriding?
Thanks
Angela
 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it would help to read some good book about the fundamentals of OO concepts. The book that I would suggest is one by Page-Meiler Jones. It is an introductory book that is very easy to read and understand and the one that I liked.
Or, Since you are already familier with Jave, a good start would be to read Thinking in Java by Bruce Eckel. It is a very easy read and he explains some fundamental OO concepts in the context of Java language.
Hope this helps.
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Overloading means to have multiple method with the same name (but different signatures) in one class. For eg:
public class Calc {
int sum(int x, int y) {}
float sum (float x, float y) {}
}
In this case the method sum has been overloaded. Note that the signatures are different.
Overriding is re-implementing a method (which is already implemented in a superclass) in a subclass. For eg:
public class Superclass {
public void printSomething() {
System.out.println("This is the superclass");
}
}
public class Subclass extends Superclass {
public void printSomething() {
System.out.println("This is the subclass");
}
}
As for Polymorphism, a one line definition would not really suffice for the concept. I suggest reading some good book. There is an excellent free digital book on Java available from www.bruceeckel.com , called Thinking in Java.
Hope that helps
Parag
 
Angela D'souza
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,
Overloading functions must be in one class or it can be in superclass, subclass?
Thanks,
Angela
 
Parag Shah
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A function may be overloaded in the same class as well as in a subclass.
Parag
 
Yes, of course, and I accept that blame. In fact, i covet that blame. As does this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic