Method Overriding, Inheritance and Polymorphism in Java - Core Java - Part -13

Поделиться
HTML-код
  • Опубликовано: 2 ноя 2016
  • Inheritance , MethodOverriding and Polymorphism in Java
    Learn:
    polymorphism in oops,
    inheritance and polymorphism Java,
    java abstraction,
    difference between inheritance and polymorphism in java,
    inheritance and polymorphism in java with example programs,
    abstraction encapsulation inheritance polymorphism in java with example,
    types of polymorphism in java,
    inheritance in oops with example,
    =======================================
    Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:
    ruclips.net/user/Naveen%20Au...
    Follow me on my Facebook Page:
    / naveenqtpexpert
    ~-~~-~~~-~~-~
    Follow my Site/Blog: www.naveenautomationlabs.com
    ========================================================
    Please watch: "Selenium & Automation Interview Preparation - By Naveen AutomationLabs"
    • Selenium & Automation ...
    ~-~~-~~~-~~-~ Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:
    ruclips.net/user/Naveen%20Au...
    Follow me on my Facebook Page:
    / naveenqtpexpert
    Let's join our Automation community for some amazing knowledge sharing and group discussion on Telegram:
    t.me/joinchat/COJqZUPB02r5sB7...
    Paid courses (Recorded) videos:
    Java & Selenium Course: www.naveenautomationlabs.com/p...
    API Course: www.naveenautomationlabs.com/p... ➡️Get Our Courses✔️
    📗 Get My Paid Courses at
    Paid courses (Recorded) videos:
    Java & Selenium Course: www.naveenautomationlabs.com/p...
    API Course: www.naveenautomationlabs.com/p...
    -------------------------------
    ✔️SOCIAL NETWORKS
    Facebook: / naveenqtpexpert
    Twitter: / naveenkhunteta
    Blog: www.naveenautomationlabs.com
    --------------------------------
    Support My Channel✔️Or Buy Me A Coffee
    Paypal: paypal.me/naveenkhunteta
    Google Pay: naveenanimation20@gmail.com
    --------------------------------
    ✔️Thanks for watching!
    देखने के लिए धन्यवाद
    Благодаря за гледането
    感谢您观看
    Merci d'avoir regardé
    Grazie per la visione
    Gracias por ver
    شكرا للمشاهدة
  • НаукаНаука

Комментарии • 128

  • @jaberahmedrana1646
    @jaberahmedrana1646 3 года назад +18

    hi naveen, i really appreciate your teaching skills. i am recommending everyone to follow his channel, you dont need to go to school just finish all of his class from here and you will be getting enough knowledge which help you getting a job. all the best

  • @JaganEtikala
    @JaganEtikala 6 лет назад +39

    Its very rare to find a Gem like you now a days..
    The way you explain is exceptional
    No one can beat you on youtube for Selenium
    Super mate…

    • @naveenautomationlabs
      @naveenautomationlabs  6 лет назад +3

      +Jagan Etikala that's a big compliment. Thanks for watching jagan

    • @himanshukhare1992
      @himanshukhare1992 5 лет назад +1

      @Naveen AutomationLabs: Sir please clarify this very confusinng things among many newbies ?
      1) Compile time or Early Binding Polymorphism. (Method Overloading)
      2) Run time or Late Binding Polymorphism. (Method Overriding)

    • @arabindamohanty2190
      @arabindamohanty2190 4 года назад +1

      @@himanshukhare1992 overloading is called as compile time polymmerphism??

  • @atishkadu2208
    @atishkadu2208 4 года назад +22

    Hi Naveen, Thanks for all your videos. It helps us a lot to clear our concepts and keep us up to date with what current market trends are. One slight correction over here would method overloading is static polymorphism(compile-time) as method which could be invoked will be decided during compile time whereas method overriding is dynamic polymorphism(runtime) as the method which needs to invoked depends on the type of object(whether it is pointing to parent/ child class) during runtime by JVM.
    I really appreciate your hard work and all the efforts you put towards our Testing community !!!

  • @ManishSharma-dd5xm
    @ManishSharma-dd5xm 3 года назад +1

    Just words are not enough to express the gratitude @Naveen..you are really a gem..hats off for your tremendous support to the testing community...

  • @reetusawhney1110
    @reetusawhney1110 Год назад +1

    :( I took hundreds of classes on oopConcepts specially over method overriding and overloading but today only understood the concept..can't express my gratitude.just ll say Ive got tears once I understood this :{ :{ thanku thanku thanks a lott Naveen!!!

  • @zeeshanabbas4419
    @zeeshanabbas4419 6 лет назад +6

    Hi, Naveen I am going through your videos it's really amazing. I must say that the way you teach is very different and understandable easily.

  • @anupamagangaraju2023
    @anupamagangaraju2023 6 лет назад +2

    I am following your complete videos .....your perspective of programs and the logics is very different from others .......I appreciate your time patience and the consistent efforts you made it here .....awaesome explanation......awesome angle of teaching the things...thanks a lot Naveen sir

  • @NPRBEST
    @NPRBEST 5 лет назад +4

    I feel satisfied and confident after watching your videos. Amazing
    thank a lot

  • @neetigogo
    @neetigogo 6 лет назад +3

    Naveen, your videos are great, just right pace,to the point and great explanation, becoming your fan now

  • @ashutoshdixit8270
    @ashutoshdixit8270 5 лет назад +2

    You are awesome...the way you explain is exceptional and easy to understand for a fresher/beginner.

  • @shikhar5300
    @shikhar5300 5 лет назад

    I was trying to understand this concept since very long but now I understood this concept. Thanks for explaining this concept in very simple and clear way, kudos to you :)

  • @pritisoni2843
    @pritisoni2843 2 года назад

    Excellent explanation.!! Love to watch you videos. Honestly I learnt Java from to watch your videos only.!! Thanks for sharing with us.

  • @bhargavitejustories
    @bhargavitejustories 4 года назад +2

    the best explanation, I have ever seen .... Thanks a lot.....

  • @pramit460
    @pramit460 5 лет назад

    Really thank you for providing such a good content video which is helping many people out here. We all should try to contribute such Knowledge videos in whichever way we can to help others as now a days there are very few such people who help others selflessly.

  • @Kalaiarasan_Balu
    @Kalaiarasan_Balu 6 лет назад +5

    I completely understand this alien concept

  • @shravankumar-ro9uk
    @shravankumar-ro9uk 4 года назад

    Hi Naveen I am your fan now your easy technique and simple teaching is great it's so easy to get taught of complex lessons
    Really great

  • @sanghamitradas40
    @sanghamitradas40 Год назад +1

    Excellent teaching

  • @anupamagangaraju2023
    @anupamagangaraju2023 6 лет назад

    after each video and the concepts I finish I feel the exact word wowwwwwww awesome....

  • @umadevi-yo3yl
    @umadevi-yo3yl 5 лет назад

    Thank u so much Naveen garu ur helping a lot to get better understanding the concepts

  • @sahilkakkar7550
    @sahilkakkar7550 6 лет назад +2

    Thank you Naveen for your help to understand very well

  • @kshitijshrivastava9881
    @kshitijshrivastava9881 6 лет назад +1

    Awesome Naveen bhai !!!

  • @satya5566
    @satya5566 6 лет назад +1

    EXCELLENT EXPLANATION

  • @k9870
    @k9870 5 лет назад

    Finally someone explaining diz concept like they are talking to beginners not seasoned engineers

  • @jamilgharwal7125
    @jamilgharwal7125 5 лет назад +1

    Great explanation, bravo

  • @ankitajaiswal4457
    @ankitajaiswal4457 6 лет назад

    such crisp and clear explanation....Thanks sir

  • @agnelthevar9950
    @agnelthevar9950 4 года назад +1

    superbly explained..

  • @ruchipandya6885
    @ruchipandya6885 4 года назад

    Hi Naveen Superb Explanations !!

  • @MohammadAlam-xx3qu
    @MohammadAlam-xx3qu 2 года назад

    Great explanation. And very clear concept. like your teaching style.

  • @priyasai935
    @priyasai935 5 лет назад +1

    No one can explain Polymorphism better than this.

  • @anushagiri4374
    @anushagiri4374 3 года назад

    @Naveen You really are a blessing. All your videos are so detailed and easy to understand. Would you be able to post a video on a particular topic, if we request one? Please.

  • @mohdshafeeq7563
    @mohdshafeeq7563 5 лет назад

    U r superb... Nice tutorial

  • @cvreddy369
    @cvreddy369 5 лет назад +2

    HI Naveen, U r the best tutor i found till date. This is my first channel which i subscribed in youtube. Thanks a lot.

    • @naveenautomationlabs
      @naveenautomationlabs  5 лет назад +1

      Keep learning buddy

    • @girishchandbind1122
      @girishchandbind1122 2 года назад

      @@naveenautomationlabs Naveen sir,
      It's not a static polymorphism it's dynamic polymorphism please check if I am wrong please correct me

  • @namratavishwaskelkar6853
    @namratavishwaskelkar6853 2 года назад +1

    Thanks Naveen!

  • @user-uu9mc9in3w
    @user-uu9mc9in3w 10 месяцев назад +1

    very helpfull naveen thank you so much

  • @cvreddy369
    @cvreddy369 5 лет назад +3

    I am learning selenium automation from your tutorial. If possible, please let me know if any chance to work under you would be great achievement in my life.

  • @renuroy2253
    @renuroy2253 3 года назад +1

    An AWSOME video

  • @pratikkadam4862
    @pratikkadam4862 2 года назад

    Thank you so much naveen...

  • @rushikeshhulsurkar8935
    @rushikeshhulsurkar8935 3 года назад +1

    Hi Navin, I m unfortunate that I found you on RUclips bit late. But i m sure I m fotnutate now with your knowledge videos.

  • @Dadirocks
    @Dadirocks 6 лет назад +4

    Naveen I have been a big fan of yours after watching your tutorials , I have started from 1 and today I have completed till 13 and it gives me immense interest in Java first time and I am keen to know what next :)
    Thanks for your contribution to this java and selenium world.

  • @KaisarAnvar
    @KaisarAnvar 2 года назад +2

    You're a GENIUS. Wish me luck, I'm about to go onto the market. Very nervous.

  • @neetigogo
    @neetigogo 6 лет назад

    When we run the java prm in eclipse, doest it compile and run it at the same time? or we can do it in two different steps?

  • @ramyab6961
    @ramyab6961 6 лет назад

    Thanks Naveen.

  • @WhiteKnight_OG
    @WhiteKnight_OG 4 месяца назад +1

    sir u are just perfect !! love u sir !! uor concept giving type is just awesome . very soon i gonna become a smart programmer & tester .
    edit 1 ->sir if we can't access child class properties after creating the object of child class . then whats the use of dynamic polymorphism , anyway we are accessing only parent class properties or common properties that are both in parent class and child class then why we have to need to use dynamic polymorphism.
    edit 2 -> so to use child class properties using top casting ...this is only use of dynamic polymorphism . Is it sir .

  • @naidugaariammai6708
    @naidugaariammai6708 2 года назад

    nice sir, good explanation

  • @supriyapawar8417
    @supriyapawar8417 4 года назад +1

    Thank you!!

  • @harinivenkateshan4613
    @harinivenkateshan4613 3 года назад +1

    You are Ama'ZING'

  • @RaviKumar-hz8cf
    @RaviKumar-hz8cf 6 лет назад +1

    Valuable

  • @FahadAli-md5yh
    @FahadAli-md5yh 3 года назад +2

    Hi Naveen! There are many online statements available where it's said that Method overloading is the compile-time polymorphism where more than one methods share the same name with different parameters or signature and different return type. Method overriding is the runtime polymorphism having same method with same parameters or signature, but associated in different classes
    In this video, you told Method overriding is Compile time polymorphism, which is opposite of above statement. Which one to consider? I'm kinda confused!
    (Help from anyone would be appreciated)

    • @ashadaya5473
      @ashadaya5473 Год назад

      same question even i have....badly need help

  • @pranayabasireddy2362
    @pranayabasireddy2362 6 лет назад +1

    Hi naveen Your videos are amazing .Thank u so much and can u pls share me the link for string concepts in java .

  • @harinderkaur5335
    @harinderkaur5335 3 года назад +1

    great help naveen sir.

  • @sathishcr6419
    @sathishcr6419 6 лет назад

    Nice Naveen, ..Can you please do videos on collections please..Having so many doubts regrading collection..Please do that Naveen.

  • @tusharmotwani5645
    @tusharmotwani5645 2 года назад +1

    Hello Naveen,
    Thanks for amazing session, but I have question here at 19:46 you mentioned that this is compile time polymorphism but compile time polymorphism can achieved only by method overloading right? and this is overriding?
    Can you please explain.
    Thanks

  • @poonamg6590
    @poonamg6590 5 лет назад +5

    Hi Naveen, Thanks for your videos. I am really learning a lot from your videos. I have a question here,
    Method overloading is compile time polymorphism and over- ridding is run time polymorphism. am i correct?

  • @vocationaldoor5733
    @vocationaldoor5733 2 года назад +1

    Hi Naveen , Thanks for teaching us so beautifully I have one query here on the page of geek for geeks i found "Note: Run time polymorphism is implemented through Method overriding. Whereas, Compile Time polymorphism is implemented through Method overloading and Operator overloading. " but in this video i learnt different. please clear this

  • @udaybenake206
    @udaybenake206 4 года назад +1

    Hi Naveen - Can we give Run time polymorphism as an example for OOPs concept used in selenium for Webdriver driver = new ChromeDriver();

  • @roopapatil2815
    @roopapatil2815 6 лет назад

    👌👌👌

  • @gautamgkp65
    @gautamgkp65 5 лет назад +1

    Superb..it's very helpful

  • @akshaymalik8315
    @akshaymalik8315 4 года назад

    Hi Naveen, great videos.. Had a question can two child objects like BMW and Honda be referenced with each other if they have some common method e.g. start or refuel. or they can only be inherited from the parent (in this case car) ...

  • @thelastjet17
    @thelastjet17 6 лет назад +1

    You do a good job explaining concepts of programming.
    Only other comment is "Vehicle" . :)

    • @naveenautomationlabs
      @naveenautomationlabs  6 лет назад +1

      Haha I dint get it :)

    • @ShubhamSehajpal
      @ShubhamSehajpal 4 года назад +1

      @@naveenautomationlabs you made a spelling mistake, its VEHICLE not VECHILE.. That's what this gentleman is referreing to.. HaHa! Awesome tutorial by the way, Thanks a ton Naveen!

  • @bhaskarvardhamana836
    @bhaskarvardhamana836 Год назад

    nice

  • @sachinsusmi1279
    @sachinsusmi1279 Год назад

    Hi @Naveen ,I have a doubt on this video. method overloading is also called as static polymorphysim and Method Overriding is also called as dyanamic polymophrism .In this video its been explained differently..does this the correct one?[on overloading method resolution taken care by compiler based on object reference variable, on overriding method resolution taken care by jvm based on the run time object]This is my understanding pls correct me

  • @payalmodi9377
    @payalmodi9377 2 года назад

    hi Naveen. in real time programming why or where would we use dymamic polymorphism?

  • @nazmak4194
    @nazmak4194 3 года назад

    Thank u soo much sir...
    One small doubt can we call main methods of one class to another class?

  • @deepthigangasani8097
    @deepthigangasani8097 3 года назад +1

    Hi Naveen, I have a question , you were talking about static or compile time polymorphism that is method overloading will come into the picture but u were talking about method overriding in the video correct me if I'm wrong.

    • @ra12896
      @ra12896 3 года назад

      I too have same dought

  • @RajuDas-zn3gx
    @RajuDas-zn3gx 6 лет назад

    Hi Navee, do you have any video for constructor?

  • @Abhisheksharma-wj5gw
    @Abhisheksharma-wj5gw 6 лет назад

    Hi Naveen,
    Where we do method Overriding in our selenium framework.Can you plz give me the example with code.
    Thanks

  • @iyerakhila123
    @iyerakhila123 5 лет назад

    Hello Naveen, I have a doubt, @24.38 , as explained by you, c1.start(); should display the output as "BMW.... Start" But I am getting the output from Car class itself..? Could you please explain..

  • @krishnapriyadumpa2631
    @krishnapriyadumpa2631 3 года назад

    Hi Naveen , How the methods are executed with out main method in method over riding concept?

  • @purushottamw
    @purushottamw 4 года назад

    Hi Naveen, I have question. I was creating same Methods for practice. However, i have received error The method stop() is undefined for the type BMW and The method refill() is undefined for the type BMW when i was using b.stop(); and b.refill(); in TestCar.

    • @purushottamw
      @purushottamw 4 года назад

      Found the solution, thank you. i missed to do the extends car while defining BMW Class

  • @nazmak4194
    @nazmak4194 3 года назад

    Can we inherit class properties of one package into class of another package under same project?

  • @RajuDas-zn3gx
    @RajuDas-zn3gx 6 лет назад

    I have implemented SUPER keyword in BMW class .
    package OOPS;
    package OOP;
    public class BMW extends Car {
    void start() {
    System.out.println(" BMW starts");
    super.start();
    }
    }
    out put coming as
    BMW starts
    car starts
    it is printing out put from the parent and child class. Is Super keyword used to avoid the method overriding?

  • @prabinkumarsahu2117
    @prabinkumarsahu2117 3 года назад

    Hello Naveen, please make a video on polymorphym.

  • @girishchandbind1122
    @girishchandbind1122 2 года назад +3

    It is not a static polymorphism it's dynamic polymorphism in method overriding please check

  • @akashsinha4583
    @akashsinha4583 6 лет назад

    is it enough for interview

  • @vineethapodduturi2678
    @vineethapodduturi2678 4 года назад

    Thanks for the vedio, can you please provide doc for all these vedios?

  • @shikhasingh1118
    @shikhasingh1118 Год назад

    Sir, one query - the Car c=new Car and Car c1 =new BMW seems to be able to access same set of Methods .what is the use then of run time Poly .Additionally ,Thanks a lot for your videos as it has helped me and many others, to kickstart learning process.

  • @vedantkulkarni6263
    @vedantkulkarni6263 3 года назад

    One query, where do we use method overriding practically in selenium

  • @Srhnu449
    @Srhnu449 5 лет назад

    Please attach the video of string manipulation concept bro ... pls ... there is no video regarding that concept ...

  • @sureshsubramaniyan3201
    @sureshsubramaniyan3201 5 лет назад

    hi Naveen,
    First of all, thanks for this concept able to understand your presentation. have a small confusion already same questions asked by some people. as referred from google, find out the details as below
    Method Overloading achieved by --->static or compile time polymorphism
    Method Overriding achieved by ---> Run time or Dynamic Polymorphism
    but in this video static or compile time polymorphism achieved by Method Overriding, so got confused here ( Method Overriding ). please clarify.

  • @zuberqazi3012
    @zuberqazi3012 4 года назад

    Hi.. Naveen In dynamic polymorphism (25:10) If we cant access c1.theftSafety() then how we can access c1.start() [O/p :: BMW-----start]. Though both Methods in the BMW class.
    Code :: Cars c= new BMW();// Dynamic polymorphism or runtime polymorphism
    c.start();
    c.stop();
    c.theftSafety();
    Kindly reply...

    • @velliangirimurugesh
      @velliangirimurugesh 4 года назад +1

      When you call C1.Start(); --> Start method is already present in BMW class as well also it is present in Car class. in Main Method during the execution it will give the priority to BMW . That is called Method Overriding. If the BMW class doesnt have any Start Method. Then the compiler will move the priority to Car Class. .
      ************************
      Code :: Cars c= new BMW();// Dynamic polymorphism or runtime polymorphism
      c.start();
      c.stop();
      c.theftSafety();
      C is obj Reference variable for BMW class .
      As Parent Class Car is holding the Object variable C.
      So when you are try to call the method using parent class is not allowed. (Child can access Parent class method where as Parent cannot access child class method) .
      Hope you understand.

  • @abhijithvarma495
    @abhijithvarma495 28 дней назад

    Hi bro, Method overloading is referred as compile time polymorphism right? Not method overriding.

  • @MN-mp1vy
    @MN-mp1vy Год назад

    At 20.21 it must be dynamic or runtime polymorphism right

  • @arjunms3345
    @arjunms3345 6 лет назад +1

    but method overloading is compile time or static polymorphism right? please reply

    • @kshitijshrivastava9881
      @kshitijshrivastava9881 6 лет назад +1

      Just try to think in terms of when a method is picked for execution.
      If there are overridden methods, which method is to be executed depends on the type of object , that is decided at RUNTIME by the JVM. So this is "runtime polymorphism".
      In case of overloaded method, the compiler decides which method is to be executed by verifying the argument list and return type at compile time. So this is "compile time polymorphism". Hope it clears your doubt :)

    • @AshishDubeyash4you
      @AshishDubeyash4you 5 лет назад

      @@kshitijshrivastava9881 Rightly said but in Video, @Naveen is mixing the concepts.

    • @kavita1385
      @kavita1385 4 года назад

      Ashish Dubey i agree with you....static polymorphism is method overloading which has no relation with the example explained here using inheritance

  • @smohapat123
    @smohapat123 6 лет назад +2

    Hi Naveen.I am referring your videos from last 1 week.You have done a Excellent work.
    I have some confusion regarding this video(
    Method Overriding, Inheritance and Polymorphism in Java - Core Java - Part -13 ).In this video you explained that Java supports static polymorphism/Compile time polymorphism by doing method overriding.But As per my knowledge
    method overloading--->static/compile time polymorphism
    Method Overriding--->Dynamic Polymorphism
    Please help me to clear my confusion

    • @avikchaks
      @avikchaks 6 лет назад

      there is no confusion , it appears he made a typo , u r correct.

    • @almajabin7898
      @almajabin7898 3 года назад

      @Sunita and @Avik No, the concept that he has explained is correct. if you call the base class methods with base class object, is called compile time polymorphism. But with parent reference which is referring to child class object, now method calling will be decided at Run Time - is called Run time Polymorphism.

  • @mogliff3414
    @mogliff3414 5 лет назад

    Compile time or runtime?

  • @ranis2715
    @ranis2715 3 года назад

    Hello Naveen, why abstract class is used when we can achieve the same output by method overriding.

    • @ranis2715
      @ranis2715 3 года назад

      Even if some features are there in parent method that can be overridden by child so now it became same as abstract class where it force the child to override the parent method. So why abstract class is required?

  • @nikitathergaonkar3908
    @nikitathergaonkar3908 5 лет назад

    Is method overloading and run time polymorphism are same concept?

  • @revathikamaraj6650
    @revathikamaraj6650 Год назад

    Hi,
    Dynamic polymorphism - c1.start() - Takes the preference of child class.
    c1.thesafety(); - Why we can't use this method.
    Only we can take if the methods are same in the child and parent class. Other methods not to be considered right.

  • @ramakrishnants7826
    @ramakrishnants7826 4 года назад

    So Polymorphism is the decision Java take when we do Method Overriding?? Am i correct??

  • @shivalikaverma7586
    @shivalikaverma7586 6 лет назад +1

    Hi, Naveen I appreciate your efforts, your videos are very well explained. But I need to correct one thing here.. Method overriding is Run Time polymorphism instead of compile time.

    • @naveenautomationlabs
      @naveenautomationlabs  6 лет назад +2

      No, the concept that I have explained is correct. if you call the base class methods with base class object, is called compile time polymorphism. But with parent reference which is referring to child class object, now method calling will be decided at Run Time - is called Run time Polymorphism.

    • @naveenautomationlabs
      @naveenautomationlabs  6 лет назад

      Method overloading is also part of compile time polymorphism.

    • @shivalikaverma7586
      @shivalikaverma7586 6 лет назад

      This means when we do upcasting and calling child class object then it is Run time polymorphism? and same method with same name concept is called as Complie Time polymorphism ??

    • @naveenautomationlabs
      @naveenautomationlabs  6 лет назад +2

      Shivalika Verma yes, coz u are calling child class methods only by using child class object reference. Compiler will be happy to call this at compile time. But in case of top casting, compiler will be confused method calling will be decided at run time.

    • @shivalikaverma7586
      @shivalikaverma7586 6 лет назад

      Thanks. (Y) . I am happy doubt is clear.

  • @LilMoonLightShine
    @LilMoonLightShine 4 года назад

    Hi Naveen,
    when I tried top casting and calling static functions of a child class through parent class object reference im still getting parent class function output only instead of BMW(Child). Please help
    package Inheritance;
    public class TestVehicle {
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    BMW b = new BMW();
    b.door();
    b.engine();
    Car c = new Car();
    Car.door();
    Car d = new BMW();
    d.door();
    }
    }
    output:
    BMW Door
    cardoor
    Car engine
    cardoor
    cardoor
    ------------parent--------------------
    -package Inheritance;
    public class Car {

    public static void door()
    {
    System.out.println("cardoor");
    }
    public static void engine()
    {
    door();
    System.out.println("Car engine");
    }

    }
    -----------child------------
    package Inheritance;
    public class BMW extends Car{
    public static void door()
    {
    System.out.println("BMW Door");
    }
    public static void safety()
    {
    System.out.println("BMW Safety");
    }

    }

    • @swarnasharma3836
      @swarnasharma3836 4 года назад

      Hi Saranya, You are trying to override a static method which is not allowed. Method overriding is basically to reuse the same method but with some changes. However, static is to retain single copy of method by all of that class objects.
      Static methods can be inherited but not overridden. If you declare the same method in a subclass, you hide the superclass method instead of overriding it. Static methods are not polymorphic. At the compile time, the static method will be statically linked

    • @ashadaya5473
      @ashadaya5473 Год назад

      overriding concept is applicable only for non static methods.

  • @SportsGyan_
    @SportsGyan_ 2 года назад

    i think it should be run time polmorphism....19:37

  • @hajeeramohamad7641
    @hajeeramohamad7641 2 года назад

    A static method cannot be overridden. But can a static method be inherited?

  • @chiragbansod4003
    @chiragbansod4003 6 лет назад

    Is it has a relationship or is a relationship the inheritance is is a relationship I guess

  • @dharaniravi216
    @dharaniravi216 3 года назад

    Method Overloading is also Polymorphism ?

  • @barshabhattacharjee6788
    @barshabhattacharjee6788 3 года назад

    For more visit : ruclips.net/video/q2RgFH1rPos/видео.html

  • @neerajyadav2349
    @neerajyadav2349 2 года назад

    has a relationship kaise? is-a hona chahiye na?