Oops! Sorry!!


This site doesn't support Internet Explorer. Please use a modern browser like Chrome, Firefox or Edge.

Default Method

Inside Interface

Interface : till jdk 1.7

by default every method inside public abstract whether you are declaring or not

you can not take concrete method inside interface

Every variable is final

  • public static final int x = 10;

  • public abstract void m1()

  • Defualt method :

              defualt method used inside interface used for declare concrete method in java 8, 

     


    Override Default method

    • if you want to override defualt implementation you can override by providing your own implementation in implemented class

     

    default method w.r.t multiple interface

    Usecase may be same defualt method available on mutiple interface

    we can solve the ambiguity problem by overriding the defualt method and calling defualt method from interface using super keyword

    static method inside Interface 

    static method is used for utility purpose in java8 and its called using Interface name