Is interface is Final in Java?


Is interface is Final in Java? 

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 final is completely pointless.
A final interface is one that cannot be extended by other interfaces .but it is senseless that we cannot implements or extends the inheritance.because to declare an interface means to implements its methods which we can't do if we mark interface as final.
So interface is never final in  java.
Lets take an example
 final interface Test{
}
Trying to declare an interface as final in Java results in a compilation error. This is a language design decision - Java interfaces are meant to be extendable.
final interface Test {}
$ javac Test.java
Test.java:1: illegal combination of modifiers: interface and final
final interface Test {}
 ^
1 error

People who read this post also read :



0 comments:

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More