Hello,
Can we make an Interface as final?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
AartiPosted Nov 17, 2011, 12:39 AM
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
AartiPosted Nov 16, 2011, 5:57 AM
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.
VulpesPosted Oct 17, 2011, 1:50 PM
You can't prevent an interface from being extended by sub-interfaces.