Hello,
Can we make an Interface as final?
Can we define interface as final modifier
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Oct 17, 2011, 9:50 AM EDT
You can't prevent an interface from being extended by sub-interfaces.
AartiRank #2,383 · 594 reputationPosted Nov 16, 2011, 12:57 AM EST
Interfaces are 100% abstract and the only way to create an instance of an interface is to instantiate a class that implements it. Allowing interfaces to be
finalis completely pointless.EDIT The questions is not as outright outrageous as I first thought. A final interface is one that cannot be extended by other interfaces but can be implemented ostensibly makes sense.
I could think of one difference between a final class and a final interface. Extending a class can compromise its integrity because it contains some state. Extending an interface simply adds operations and cannot compromise the integrity of the implementation because the interface is stateless on its own.
Thanks.
AartiRank #2,383 · 594 reputationPosted Nov 16, 2011, 7:39 PM EST
We can not made interface as final. It will give you compile time error
"Illegal modifier for the interface "Class name"; only public & abstract are permitted"
Logically also it will destroy the whole purpose of inter face.
Regards
Aarti