Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Polymorphism applies to overriding, not to overloading"?

I just read this line in book "Sun Certified Java Programmer" (page number-158) by Kathy Sierra and Bert Bates who worked as Master trainer at "Sun microsystems":

Polymorphism applies to overriding, not to overloading.

But some other books and articles say overloading is also a form of polymorphism.. i'm confused.. Please help..

like image 481
Nakul Patekar Avatar asked Oct 16 '13 14:10

Nakul Patekar


People also ask

Does polymorphism apply to overriding?

Overriding is a form of polymorphism that is used in Java to dynamically bind the method from the subclass in response to a method call from a subclass object referenced by superclass type.

Is method overloading and overriding is polymorphism?

Overriding and overloading are the core concepts in Java programming. They are the ways to implement polymorphism in our Java programs. Polymorphism is one of the OOPS Concepts. Screenshot of Java code with arrows pointing at instances where overloading and overriding are occurring.

Why polymorphism is not applicable for method overloading?

Polymorphism means more than one form, same object performing different operations according to the requirement. Method overloading means writing two or more methods in the same class by using the same method name, but the passing parameters are different.

Can overriding method be overloaded?

No. Method overloading is used to increase the readability of the program. Method overriding is used to provide the specific implementation of the method that is already provided by its super class.


1 Answers

Don't believe the other books. Late binding (wiki) (with overriden/inherited methods) is polymorphism. Static binding is what applies to overloading.

The two bolded expressions are concepts you should familiarize yourself with as soon as possible. There are a number of available resources. Maybe start here.

like image 92
Sotirios Delimanolis Avatar answered Oct 02 '22 22:10

Sotirios Delimanolis