Polymorphism in Kotlin with Example | Kotlin For Beginners CheezyCode #20

  Рет қаралды 30,102

Cheezy Code

Cheezy Code

Күн бұрын

Пікірлер: 46
@RaajKanchan
@RaajKanchan 3 жыл бұрын
The best video tutorial to understand Polymorphism. Simply Awesome 👌👌👌
@rohittakalkar9252
@rohittakalkar9252 8 ай бұрын
[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.
@snooringcode6594
@snooringcode6594 4 жыл бұрын
Videos like this really deserve a like. Make a video on interface and how it is beneficial in multiple inheritance.
@CheezyCode
@CheezyCode 4 жыл бұрын
Sure brother in progress
@TheAbhidugar
@TheAbhidugar 3 жыл бұрын
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.
@CheezyCode
@CheezyCode 3 жыл бұрын
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...
@TheAbhidugar
@TheAbhidugar 3 жыл бұрын
@@CheezyCode hanji bas aaj kotlin puri kar leni fir Android shuru karna
@anmolverma075
@anmolverma075 Жыл бұрын
Sir ,really a great explanation! Jaise aap smjhate ho ,blkl next level hai!
@riteshmukhopadhyay6922
@riteshmukhopadhyay6922 3 жыл бұрын
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👏🙌
@CheezyCode
@CheezyCode 3 жыл бұрын
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
@riteshmukhopadhyay6922
@riteshmukhopadhyay6922 3 жыл бұрын
@@CheezyCode ooh ye nhi malum tha, thanks for the info 😁👍
@CheezyCode
@CheezyCode 2 жыл бұрын
Dynamic method dispatch is a way of implementation of polymorphism in Java or Kotlin....
@chndraja
@chndraja 3 жыл бұрын
Type inference was amazing... Thank you for this amazing video....
@ManishKumar-eh4ol
@ManishKumar-eh4ol 3 жыл бұрын
Best lectures on kotlin
@CheezyCode
@CheezyCode 3 жыл бұрын
Thank you 🤘
@shahriarsharif6736
@shahriarsharif6736 3 жыл бұрын
Thank you from Bangladesh. Please add English subtitle.
@naimeimran3247
@naimeimran3247 3 жыл бұрын
Thanks Sir
@amanjotkaur3964
@amanjotkaur3964 2 жыл бұрын
Usefull vedio don't miss
@CheezyCode
@CheezyCode 2 жыл бұрын
Thanks Daman
@wasimakrambiswas4216
@wasimakrambiswas4216 3 жыл бұрын
I am new in kotlin .I might be wrong . but In General term it is not satisfying rules of POLYMORPHISM . it is satisfying concept about " CASTING " ...
@CheezyCode
@CheezyCode 3 жыл бұрын
Let's discuss 🙂
@CheezyCode
@CheezyCode 3 жыл бұрын
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..
@wasimakrambiswas4216
@wasimakrambiswas4216 3 жыл бұрын
Okk ... Thank you ... 🙂
@cheems08213
@cheems08213 Жыл бұрын
sir im confused, i think polymorphism is function overloading and overriding, what you have explained in the video is upcasting
@CheezyCode
@CheezyCode Жыл бұрын
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.
@cheems08213
@cheems08213 Жыл бұрын
@@CheezyCode ok sir thank you for replying, ill definitely read more on this topic
@kaushikpaul6583
@kaushikpaul6583 3 жыл бұрын
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
@CheezyCode
@CheezyCode 3 жыл бұрын
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.
@fitnessbrandspormotion
@fitnessbrandspormotion Жыл бұрын
4:58
@tuananhtran7518
@tuananhtran7518 Жыл бұрын
please turn on subtitles :(
@ksujalpatel
@ksujalpatel 2 жыл бұрын
Examples maybe made more easier to understand
@CheezyCode
@CheezyCode 2 жыл бұрын
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...
@ksujalpatel
@ksujalpatel 2 жыл бұрын
@@CheezyCode you done really Good Job, i appreciated Thanks you !
@nikhilmandlik355
@nikhilmandlik355 3 жыл бұрын
It's Upcasting
@CheezyCode
@CheezyCode 3 жыл бұрын
No it's not...
@CheezyCode
@CheezyCode 3 жыл бұрын
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
@ronitrojasara
@ronitrojasara 2 жыл бұрын
hey! search on the internet it is not polymorphism
@CheezyCode
@CheezyCode 2 жыл бұрын
Ok
@CheezyCode
@CheezyCode 2 жыл бұрын
Please provide the links as well for more information.... Thanks
@CheezyCode
@CheezyCode 2 жыл бұрын
Ek info meri taraf se - keywords ka koi mol nahi h....concepts clear hone chaiye
@007ayansinha
@007ayansinha 4 жыл бұрын
isko polymorphism nai upcasting kehte hai 🙄
@jatinvashisht4293
@jatinvashisht4293 3 жыл бұрын
Clear your basics bro !
@007ayansinha
@007ayansinha 3 жыл бұрын
@@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.
@CheezyCode
@CheezyCode 3 жыл бұрын
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 🤘
@007ayansinha
@007ayansinha 3 жыл бұрын
@@CheezyCode appreciated for clarification, anyway watched all your videos on Kotlin. Really helpful. Looking more :-)
Война Семей - ВСЕ СЕРИИ, 1 сезон (серии 1-20)
7:40:31
Семейные Сериалы
Рет қаралды 1,6 МЛН
Какой я клей? | CLEX #shorts
0:59
CLEX
Рет қаралды 1,9 МЛН
OOP 3 | Principles - Inheritance, Polymorphism, Encapsulation, Abstraction
2:12:51
Learn Kotlin in 12 Minutes
12:01
Rahul Pandey
Рет қаралды 348 М.
The Flaws of Inheritance
10:01
CodeAesthetic
Рет қаралды 993 М.
Encapsulation in Kotlin
14:28
Neat Roots
Рет қаралды 4,9 М.
The Basics - Kotlin Coroutines
10:44
Stevdza-San
Рет қаралды 90 М.
Fundamental Concepts of Object Oriented Programming
9:16
Computer Science Lessons
Рет қаралды 981 М.
init block in Kotlin | Amit Shekhar | @OutcomeSchool
5:08
Amit Shekhar
Рет қаралды 11 М.
Advanced Kotlin: Generics, Type Erasure, and Reflection Explained
23:00