What is the difference between the two?
A super class having myMethod(int a)
and an inheriting class having the same method,
Is this overriding or polymorphism?
I am clear with the difference b/w overriding and overloading, but the polymorphism and overriding seems the same. Or are they?
Overriding is when you call a method on an object and the method in the subclass with the same signature as the one in the superclass is called.
Polymorphism is where you are not sure of the objects type at runtime and the most specific method is called. Therefore the behaviour of the method called may differ, depending on the objects type at runtime.
Overriding is a type of polymorphism along with overloading and dynamic (late) binding. You can see more details here about the different types.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With