0

Polymorphism is the ability of a class instance to behave as if it were an instance of another class in its inheritance tree.

Method Overriding Can be see as Polymorphims.

This Snip if from site www.javatpoint.com

enter image description here

It says we can perform Polymorphism in Java by method Overloading and Overriding. I think Overloading is a different Concept Some Says Overloading is Static Polymorphism? How?

Method overloading does not change behaviors at runtime. Overloading gives you more choices for argument lists on the same method name when you're writing and compiling the code, but when it's compiled the choice is fixed in code forever.

AshishUpadhyay
  • 179
  • 1
  • 15

3 Answers3

0
Static binding = Compile-Time binding = Early binding -> Method overloading
Dynamic binding = Run-Time binding = Late binding     -> Method overriding

If there is an ambiguity between overloaded methods for example, it is determined by compiler, so at compile-time. The case is kinda static polymorphism.

0

Polymorphism is an OOPS concept that eases the user to have better and easily understandable naming convention.

Method overloading is for creating methods of same name that can be used with varying number of arguments. like Area method that have 2 arguments needed for rectangle while single for square. so this king of polymorphism is method overloading and the binding can be done at compile time. Area(int length, int breadth); Area(int side)

Method overriding is another way where the binding takes place at run time. That means the method which is going to be executed will be decided at the time of Run time. This is used in case of Inheritance where child class overrides the functionality of parent class.

As I understand your confusion is that you believe that Polymorphism means method to be executed or should not be known to user un-till execution while polymorphism just means one name can be used at several places. Poly means Many. phism means Faces.

That is one name can be used at many places without any issues.

Abhishek kumar
  • 148
  • 1
  • 2
0

Easy way to remember,

OverLoading - CompiLe Time Polymorphism

OverRiding - Run Time Polymorphism

Overloading allows different methods to have same name, but different signatures where signature can differ by number of input parameters or type of input parameters or both. Overloading is related to Compile time (or static) polymorphism.

Useful Link : enter link description here

Overriding is a feature that allows a subclass or child class to provide a specific implementation of a method that is already provided by one of its super-classes or parent classes.

Useful Link : enter link description here