educative.io

Educative

Why does Abstract class has constructor while Interface don't in Java 8?

As we know in Java 8 default methods are introduce, so shouldn’t Interface must have a constructor as the case is with Abstract class.
Please correct me if I am wrong.

Hi Twinkle_Anand,
The problem that you get when you allow constructors in interfaces comes from the possibility of implementing several interfaces at the same time. When a class implements several interfaces that define different constructors, the class would have to implement several constructors, each satisfying only one interface but not the others. It will be impossible to construct an object that calls each of these constructors. Now in Java 8, default methods are introduced. If any new method needs to be added, then provide a default implementation for this new method inside the interface itself, which is not a constructor. Constructors are still not feasible in interfaces. If you want to read further about the default method introduced in Java 8, you can check out this link: