Java / Design Patterns
Explain Composite design Pattern in Java.
Composite pattern is core Java design pattern, which allows you to treat both the whole and part of the object to treat in similar way. Client code that deals with the Composite or individual object doesn't differentiate on them, it is possible because Composite class also implement same interface as there individual part.
One of the good example of Composite pattern from JDK is JPanel class, which is both Component and Container. When paint() method is called on JPanel, it internally calls paint() method of individual components and let them draw themselves.
More Related questions...