Default methods and private methods

When you want to add additional functionalities in the interface, the classes that implements it gets collapsed. So inorder to avoid it, you are allowed to create default methods, which can be accessed via tha classes and can be overridden also. This makes us to easily update tha interface time to time which bothering its implementations in the classes.

Private methods inside interface: 
Having private methods can help you in creating a well structured default methods in your interface. We know that private methods cannot be accessed via other classes but the default methods and other methods in the interface can access them. Hence it is useful to structure the methods inside the interface.

Popular posts from this blog

The third parameter - Event bubbling and Event capturing

Binary Sreach Algorithm : Optimized way to get the index of the mid element

Abstract classes