Polymorphism is an oops concept
poly means many and morphism means forms - so many forms
by method over loading and method over riding we can achieve polymorphism in java
method overloading is compile time polymorphism
method overriding is run time polymorphism
METHOD OVERLOADING
------------------------------------------
method over loading can be achieved by
changing number of parameters of method
changing data type of parameter
Note: we can't achieve method over loading by changing return type of method
automatic promotion happens
byte - short - int -long - float - double
char - int
when parent class and child class data types are there child class data type method will get priority
if both data types are of child class then we get ambiguity error
METHOD OVERRIDING
------------------------------------------
When child class is not satisfied with parent class implementation then child class can over ride parent class method
whatever method parent class has by default available to child class through inheritance, if child class not satisfied with parent class implementation then child is allowed to redefine the method based on its requirements. This process is called method overriding
The parent class method is called 0ver ridden method
the child class method is called over riding method
In overriding method resolution always takes care by JVM based on run time object and hence overriding is also considered as run time polymorphism or dynamic polymorphism or late binding.
In overloading method resolution always take care by compiler based on reference type so it is called compile time polymorphism
Note: In method over riding method signature should be same
00:10 method over loading by changing number of parameter
03:22 by changing data type of parameter
04:38 by changing return type of method ?
05:43 automatic promotion in method overloading
07:19 parent and child class data type
10:41 method overriding
13:12 super keyword
Follow me on Instagram
/ smart_engineer_youtube
On this page of the site you can watch the video online method overloading and method overriding in java | polymorphism in java with a duration of hours minute second in good quality, which was uploaded by the user Smart Engineer 08 June 2023, share the link with friends and acquaintances, this video has already been watched 1,076 times on youtube and it was liked by 12 viewers. Enjoy your viewing!