0 votes
in JAVA by
What is the interface? Why you use it if you cannot write anything concrete on it?

1 Answer

0 votes
by

The interface is used to define API. It tells about the contract your classes will follow. It also supports abstraction because a client can use interface method to leverage multiple implementations e.g. by using List interface you can take advantage of random access of ArrayList as well as flexible insertion and deletion of LinkedList. The interface doesn't allow you to write code to keep things abstract but from Java 8 you can declare static and default methods inside interface which are concrete.

Related questions

+1 vote
asked Oct 11, 2020 in JAVA by SakshiSharma
+1 vote
asked Apr 15, 2021 in JAVA by SakshiSharma
...