#67 More on Interfaces in Java

แชร์
ฝัง

ความคิดเห็น • 22

  • @grrlgd3835
    @grrlgd3835 ปีที่แล้ว +12

    I started with Navin 3 years ago. I've watched lots of others since aswell but he remains the best.

  • @masteradvisor594
    @masteradvisor594 ปีที่แล้ว +3

    sir u r perfect always do crisp video upto point. Thank u so much for such amazing playlist.

  • @nguyenquanghau7158
    @nguyenquanghau7158 ปีที่แล้ว +4

    I have an idea for that, we just change type data, for example, we declare that A obj = new B(), and we could you some methods that belong to the A class. But we want to use the run function that belongs to the B class, simply using this command ((B) obj).run(). It will work well.

    • @suraprashanthreddysura487
      @suraprashanthreddysura487 ปีที่แล้ว

      Yes it worked, but don't you think it is written purposely . Like behind it we have a reason?

    • @psnvenkat2284
      @psnvenkat2284 ปีที่แล้ว

      This is call method casting for obj reference. Am i correct?

    • @merrylia8316
      @merrylia8316 ปีที่แล้ว

      is this a one-time use(liek after that command the reference is still A)? or does is change the reference of the obj from A to B?

  • @psnvenkat2284
    @psnvenkat2284 ปีที่แล้ว +3

    Also there are new features for interfaces in new JDK version, where we can use default method and static method with implementations inside a interface class. FYI

  • @merrylia8316
    @merrylia8316 ปีที่แล้ว +1

    great explanation. thank you so much 🤩🤩

  • @jatinsharma3792
    @jatinsharma3792 11 หลายเดือนก่อน +1

    You missed why we use the default private and static method in interface after Java 8 ?

  • @batambuzestephen8243
    @batambuzestephen8243 9 หลายเดือนก่อน

    I also observed you can extend a normal class and implement an interface within one class

  • @Shalini-g5c6u
    @Shalini-g5c6u หลายเดือนก่อน

    If you could explain method chaining and calling these methods, that would be great.

  • @ryansinclaire8463
    @ryansinclaire8463 ปีที่แล้ว

    You're saving my life! Thank you!

  • @Trading_Club007
    @Trading_Club007 ปีที่แล้ว

    you're saving my money

  • @vinny4161
    @vinny4161 ปีที่แล้ว +2

    Better to create class B object with reference B so that we can access all methods of interfaces and class B

    • @TuxTuxedo-oc9kg
      @TuxTuxedo-oc9kg ปีที่แล้ว +1

      I asked myself the question and tried it out since I was not sure what would happen.
      All of a sudden I love interfaces lol. You can restrict by making the object of either type 1 or 2 (interface 1 or 2) or you can make it access all interfaces by instantiating an object with the type of the implementing class so it gets access to both interfaces since the class implements both.
      even works if the interfaces methods have the same name, since they have no body you have to implement the method body once yourself.
      cool stuff!

    • @merrylia8316
      @merrylia8316 ปีที่แล้ว +1

      ​@@TuxTuxedo-oc9kgomg I just realized by reading your comment that I can access the methods in both interface A and X by creating an object of class B with class B as the reference. different approach than what sir navin did in this video.

  • @bhaskarreddy.b2818
    @bhaskarreddy.b2818 ปีที่แล้ว +1

    Sir even class b also should become abstract because the methods we using are abstract in interface class

    • @uday2159
      @uday2159 ปีที่แล้ว

      The B class should be abstract when we not define all abstract methods in it and later we can define remaining methods in sub class of B.
      Then finally the subclass of B should be non abstract class.

  • @ast453000
    @ast453000 2 หลายเดือนก่อน

    Ok cool but I don't understand what the "need" for interfaces is here, since you only show that we can use interfaces as well as parent classes.

    • @prabhakarpandey8472
      @prabhakarpandey8472 2 หลายเดือนก่อน

      If all methods are abstract, we can go with interface,
      But if it is partial like any of the method is concrete then we can go with abstract class

  • @target__iit
    @target__iit 8 หลายเดือนก่อน +3

    (Next Video) Need of Interface in Java -> th-cam.com/video/AG_7wWFBquQ/w-d-xo.htmlsi=Pb8fNRY3lLjxzrL7

  • @surya-xy7wc
    @surya-xy7wc ปีที่แล้ว

    Sry mapla I'll not interested😜