I have a long standing doubt. Could someone please tell me whether method overloading is a form of polymorphism or is it something completely different?
I have a long standing doubt. Could someone please tell me whether method overloading
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Method overloading is just a syntax sugar allowing you to have methods with same name but different arguments. It has nothing to do with polymorphism. Method overloading is typically used to define two methods accepting different arguments, e.g.:
or to skip certain parameters and use some defaults:
Method overriding, on the other hand, is a foundation of inheritance and is more closely related to polymorphism.