Win a copy of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 this week in the Spring forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

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
 
Arch enemy? I mean, I don't like you, but I don't think you qualify as "arch enemy". Here, try this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic