I am a beginner in Java. I have a question about the abstract method in Interface. Is the following sampleMethod() an abstract method? My understanding is that it is not an abstract method due to System.out.println. Am I correct?
default void sampleMethod() {
System.out.println("Am I abstract method?");
}
Thanks in advance!
The sampleMethod() isn't an abstract method it is a default methode, which means that you can call this Methode at any implementation, because this is the default methode which will be called. Furthermore you can override this methode in your implementation but if you do not it wil simply call your default methode from the interface. So you don't have to override/implement it in your implementation class.
But keep in mind that even with a default methode in your interface you can't manage any variables if you wont to do this use an abstract class like this