I was going through an interface in Java from W3c
In Why And When To Use Interfaces?, they have mentioned
1) To achieve security - hide certain details and only show the important details of an object (interface).
but I wasn't able to comprehend how is interface helps in hiding details or security.
In their notes of an interface, they have the following point
- Interface methods are by default abstract and public
- Interface attributes are by default public, static and final
Based on my understanding of interface, it looks more like interface helps in decreasing the number of error in code because
- Interface methods do not have a body - the body is provided by the "implement" class
- On implementation of an interface, you must override all of its methods
So we declare all the methods with their accessibility, return type and name and when we implement those methods, if we forgot to create a method which we haven't declared in our interface, it's going to throw an error.
Can someone help me in comprehending the relation of the interface in security?