Posts

Design Patterns

Creational Design Patterns 01. Singleton Ensure a class has only one instance. 02. Factory Method Encapsulate creation of concrete objects. 03. Abstract Factory Create families of related objects. 04. Builder Build complex objects step by step. 05. Prototype Create objects by copying existing instances.

Functional Interface

Image
Definition - A functional interface is an interface that contains strictly only one abstract method but may or may not contain one or more default methods or static methods. Below are examples of the valid functional interface definition. With abstract method only   With all allowed methods  Working code snippet   Below are examples of the invalid functional interface definition. With no methods With multiple abstract methods   Points to remember here are as below, @FunctionalInterface annotation is optional. Abstract method can only be public or package-private.  Static method allows all access modifiers except protected. Default method allows only public and package-private.