Polymorphism in OOP - Kotlin

Поділитися
Вставка
  • Опубліковано 15 жов 2024
  • In this video we will talk about polymorphism in kotlin in detail. This video is based on the important culture of object-oriented programming, how it works in Kotlin. We'll also see how different types of objects are integrated through a single function. Through this video you will understand more about Polymorphism in Kotlin and also understand its benefits.
    इस वीडियो में हम कोटलिन में बहुरूपता के बारे में विस्तार से बात करेंगे। यह वीडियो ऑब्जेक्ट-ओरिएंटेड प्रोग्रामिंग की महत्वपूर्ण संस्कृति पर आधारित है कि यह कोटलिन में कैसे काम करता है। हम यह भी देखेंगे कि कैसे विभिन्न प्रकार के ऑब्जेक्ट एक ही फ़ंक्शन के माध्यम से एकीकृत होते हैं। इस वीडियो के माध्यम से आप कोटलिन में बहुरूपता के बारे में और जानेंगे और इसके लाभों को भी समझेंगे।

КОМЕНТАРІ • 10

  • @sidharthsharma7897
    @sidharthsharma7897 3 місяці тому +2

    //Two types of Polymorphism in kotlin ->Static and Dynamic
    open class A{
    fun hello1(){
    println("Hii from the base class")
    }
    fun sum(a:Int,b:Int):Int{
    hello1()
    return a+b
    }
    }
    class B:A(){
    fun hello(){
    println("Hii form the sub class")
    }
    fun sum(a:Int,b:Int,c:Int):Int{ //Function overloading
    //Dynamic Polymorphism(Run time binding)
    hello()
    return a+b+c
    }
    }
    fun main() {
    val obj=B()
    val result=obj.sum(12,32,4)
    println(result)
    }
    ////Polymorphism Static or compile time polymorphism
    //open class Father { //we have to open a class for inheritance //Base class
    // open val car="Bmw"
    ////We have to open the variable we are overriding in the parent class
    //// fun carName(){
    //// println("Father has a $car car.")
    //// }
    //}
    //
    //class child: Father() { //sub class
    // override val car="Audi"
    // //we have to override the variable of same name in the child class
    // fun carName(){
    // println("Child has a $car car.")
    // println("Father has a ${super.car}.")
    // //we use super for accessing the variable in parent class
    // // with the same name as in the child class
    // }
    //}
    //fun main() {
    // val obj1=child()
    // obj1.carName()
    //// println(obj1.car)
    //}
    Am i correct??
    Please respond

  • @sidharthsharma7897
    @sidharthsharma7897 3 місяці тому +1

    why do we get the answer from the class we have made object from, when the function name is same in both the classes in function overloading?

  • @Exp-e6c
    @Exp-e6c 11 місяців тому +2

    Function app hi batay hay lekin function me khi vhi overloading ke bare me nhi batay hay aap

  • @Jawad_Ahmad_01
    @Jawad_Ahmad_01 Рік тому +2

    method overloading is dynamic or static ??? (at 1.57 minute of this video)

    • @rishikesh4498
      @rishikesh4498 Рік тому

      Compile/Static poly = Method overloading
      run/Dynamic poly = Method overriding

  • @dishaswarajsoft2834
    @dishaswarajsoft2834 Рік тому +2

    Good

  • @DhruvahDev
    @DhruvahDev 4 місяці тому

    Nice tutorial!

  • @STARSOULEDITS
    @STARSOULEDITS 7 місяців тому

    ye banda sadharan concept ko bhi muskil kr de rha h

  • @STARSOULEDITS
    @STARSOULEDITS 7 місяців тому

    codes me phle khud confirm ho ja bhai tb padhane baith jana :(