Interface Methods
In this tutorial, we are going to discuss interface methods in Java. Whether we are declaring or not, every interface methods are by default public and abstract.
E.g
interface Interf {
void m1(); // public abstract void m1()
}
public: To make these methods available for every implementation class.
abstract: Because interface methods specify requirements but not implementation.
Hence the following method declarations are equal inside the interface
void m1()
public void m1()
abstract void m1()
public abstract void m1()
As every interface method is by default public and abstract, the following modifiers are not applicable for interface methods.
- private
- protected
- <default>
- final
- static
- strictfp
- synchronized
- native
That’s all about Interface Methods in Java. If you have any queries or feedback, please write us email at contact@waytoeasylearn.com. Enjoy learning, Enjoy Java.!
Interface Methods