It was hard to grasp in the beginning but after reading few articles and again watching your video, run time polymorphism is crystal clear. And you had already explained compile-time polymorphism that technique is function overloading, right? Thanks, Cheezy guy👏🙌
Polymorphism ka actual meaning dynamism se hai...but kaafi books overloading ko compile time polymorphism btati hai...toh consider kar skte ho...but crux yehi hai ki code future ready hojata hai if we use it correctly
4:58 agar child classes me new methods add hote hai aur unhe access karne ke liye naya object banana padega? like: val circle = Circle(). btw aapki saari videos me dekh raha hu kotlin ki. isse badhiya explanation kahin nahi hai. aapne har point ko explain kia hai. Polymorphism ka advantage aaj pura clear ho gaya jabki me java ab kuch se kar bhi raha tha. par ab saat janmon tak yaad rahega. thank you cheezy bhaiya.
Thank you Abhishek. Yes in that case reference should be of type circle then only you will be able to call new methods of circle. Aur comment ne dil khush kardiya....😁abstract aur interface aur jyada majja aayega... Insta pe short notes bhi hai...Ho ske toh please share these videos...
[Important to understand]: Only overridden methods/properties in the child class are accessible through a reference to the parent class pointing to an instance of the child class, but other properties or methods specific to the child class won't be directly accessible through that reference And this is the reason why overriding is taught before polymorphism.
Hii, here circle and shape are the base class reference, holding the memory of Circle & Square class objects respectively. But later u have created array of objects of three different classes which are passed to the calculateArea() and then individual objects stored as array elements are called and it is obvious that it will call its own memory locations. Then there is no use of the first two lines written in main()?? I can omit that...right?? Please guide
Yes...no need of those 2 lines then.... Main point of this video - in calculate areas method you can pass object of any class that inherits from shape class. Whether you have that in your project currently or a new class will be added in future. Body of that method will remain unchanged.
Overriding ka benefit kya h?... Object hold kar rahe ho parent object mei but uske andar child ka object bhi ho skta hai. Runtime pe decide hota h ki actually mei parent ka reference kis object ko hold kar rha h...jis bhi child object ko hold kar rha hoga uska method call kar diya jata hai...this is polymorphism. This is not upcasting. This is how polymorphism works i.e. at runtime it is decided to call the method based on the type of the object. Upcasting is simply holding a child object inside parent reference. For e.g. in Java - I can do this Object o = any object This is upcasting because Object is the parent class of all the objects. I can safely store any object using parent's reference. Let me know if you need more clarity. Or you can refer good sources like Head First for more information. I have read Head First Java thrice to clear these OOPs concept.
Waise ye crux hai iska - jab thoda code likhoge toh clear hojayega ..it is same as any other programming language. I have explained the advantage we get by writing polymorphic code..
Examples are based on continuation...I am assuming you have watched previous videos as well...just for OOPs concept...if you start from classes and objects video - it will make more sense...
Watch its other part too - you will be able to understand the real polymorphism...I have explained the crux of this...things will make sense when you will write more code using this approach
@@jatinvashisht4293 How well versed are you in Object-oriented? please watch 3:10 again and it will clear your doubt. Anyway its ok to live like as an ok, if even if you don't make it further.
It's ok guys...let it be....I have created this video based on my knowledge for over 11 years. Just appreciate the whole concept whether it's upcasting or polymorphism. But just to be clear - watch the whole video - polymorphism is only possible if we have upcasting. I have written 2 points for the complete definition. 1st point is upcasting and other one is just using that concept. Both points are required. Cheers from CheezyCode 🤘