Rahul Agrawal Rahul Agrawal - 3 months ago 8
Java Question

Is Interface remain fully abstract after adding default method in java 1.8?

Is Interface remain fully abstract after adding default method in java 1.8?

I am sorry if I was not able to state the question clearly.

Answer

Even if you have only one default method in your interface, it will be abstract. You will have to provide implementing class to instantiate an object. Note that default methods added in Java 8 has special purpose. From Java doc:

Default methods enable you to add new functionality to the interfaces of your libraries and ensure binary compatibility with code written for older versions of those interfaces.

So you should use default methods judiciously.

Comments