Why can’t we create an object to interface in Java?

We can’t create object of interfaces because of the reason that :

Interface is basically a complete abstract class. That means Interface only have deceleration of method not their implementation. So if we don’t have any implementation of a method then that means if we create object of that interface and call that method it compile nothing as there is no code to compile.

To overcome this, firstly we have to create class that implements that interface means that class is implementing the methods of that interface. Now when you create object of this class it gives u the permission to access all methods of interface with their implementation in the class.

Be the first to comment

Leave a Reply

Your email address will not be published.


*