#7.6 Java Tutorial | Default method in Interface

Поделиться
HTML-код
  • Опубликовано: 20 янв 2025

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

  • @Mona001-01g
    @Mona001-01g 3 года назад +5

    I think the difference in Abstract class and interfaces is that we do not have to extend all the methods in abstract class while all methods will need to be implemented in interface which is not always what we would want to do.

  • @svenschroder9781
    @svenschroder9781 7 лет назад +7

    Your explanations are really great! Thanks a lot for your work.

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

    Thank you for your explanations. It's clear my doubt how to implement default method but another doubt was created i.e. what is the use of the default method in Interface? why we use it? where its use in the real world?.
    Thank you in advance

  • @MohinPatel
    @MohinPatel 7 лет назад +1

    Can you start Tutorial series on how to make extensions for app inventor ?? Please reply !

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

    Wow, I glad I found this channel.

  • @CodingShiksha
    @CodingShiksha 7 лет назад

    Sir I want to ask you when we have a default constructor already built within java and when we write our custom constructor which one gets precedence and why

    • @meharban-singh
      @meharban-singh 7 лет назад

      Coding Geeks Think of self created constructor as an "overridden" constructor, which overrides the default one, so you cannot use default one by any means.

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

    Can we have only default method in interface without any public abstract method?.If so ,how to call that default method?

  • @AmitKumar-fx7kv
    @AmitKumar-fx7kv 6 лет назад +1

    Hello sir, as i have tested we can also define methods in interface using static keyword. Can you explain this?

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

      you can write default as well as static methods in your interface. Here in your implementation class you can directly use static method with the help of interface name where as you need to use super keyword for the default method. e.g.
      interface DefaultInterface{
      default void method1() {
      System.out.println("I am Deafult method from DeafultInterface");
      }

      static void method2() {
      System.out.println("I am static method from DeafultInterface");
      }
      }
      public class DefaultInterfaceTest implements DefaultInterface {

      void showUses() {
      DefaultInterface.method2();
      method1();
      DefaultInterface.super.method1();
      }

      public void method1() {
      System.out.println("I am Deafult method from DefaultInterfaceTest");
      }
      public static void main(String[] args) {
      new DefaultInterfaceTest().showUses();
      }
      }
      output:
      I am static method from DeafultInterface
      I am Deafult method from DefaultInterfaceTest
      I am Deafult method from DeafultInterface

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

    Sir can't we use lambda expressions for default methods in Interface????? Plz reply 🙏

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

    Sir one suggestion plz provide all these example code in description of your video

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

    Does lambda expression only works with abstract methods of functional interface and not with default methods??

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

      Yes only the one abstract method will work.

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

    One doubt!!
    Imagine we have two interfaces having same method names and it's implementation?
    Can a class implement these two interfaces?
    Which interface implementation will the class be inheriting?

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

      In 1.7, it didn't matter as the implementing Class would overide the method and there was no ambiguity if the method name was same in both interfaces!

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

      Just tried it and the result is that you have to override the method in this case. Like an abstract method. Checked exception for "unrelated defaults" occurs otherwise.

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

    this default method doesn't run in my IDE

  • @stephanieezat-panah7750
    @stephanieezat-panah7750 Год назад

    excellent video. thank you

  • @virendrapatel775
    @virendrapatel775 7 лет назад

    REALLY NEW 👍👌👌

  • @saikumarperamsetty
    @saikumarperamsetty 10 месяцев назад

    As a Career GAP Candidate StartUp Companies Lo Job Ela Techukovaalo Cheppandi Sir (or) Mam🙏🙏🙏??
    As a Career GAP(6 years) Student How to to get Java Developer Job in this Year 2024???
    Hi, I have a 6 years CAREER GAP. how can I get JAVA DEVELOPER Job in 2024 ???
    Two companies(ABC & XYZ) lo job vachindhi fake pettanu & alage 1.5 months 2 Companies lo Work Chesanu, Now i am looking for Job, my doubt is Those 2 companies are creating my pf or Not? further in future is it Effect my carrier?
    hi, How to get job in PayRoll Companies?? and How to Find PayRoll Companies?

  • @hariharavelank330
    @hariharavelank330 5 месяцев назад

    Thanks a lot bro🎉

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

    Then why can't we use abstract class instead of default ......

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

      abstract class and default method are different ....u can say "why not abstract class instead of Interface" but not "why not abstract class instead of default method" because default method is a part of Interface...but not whole interface.....i hope this makes sense :)

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

      @@srijalkc1975 can we use lambda expressions for default methods in Interface???

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

    could I write more than one default methid in interface?

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

    geiles Video, danke!

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

    Excellent

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

    Thanks😺.

  • @rahulgoti3864
    @rahulgoti3864 7 лет назад

    Thank You

  • @harekrishna7877
    @harekrishna7877 Месяц назад

    Date: 22-11-2024
    Day: 04

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

    You never give reply to anyone.That's not Good...