Composite pattern is used where we need to pleasure a group of objects in similar way as a single object. Composite pattern compose objects in term of a tree structure to stand for part as well as whole hierarchy. This type of design pattern comes under structural pattern as this pattern creates a tree structure of group of objects.
This pattern creates a class that contains group of its own objects. This class provides ways to change its group of same substance.
We are demonstrating use of composite pattern via following instance in which we will explain employee’s hierarchy of an organization.
We have a class Employee which acts as combination pattern performer class. CompositePatternDemo, our demo class will apply Employee class to add department level hierarchy and print all employees.
Create Employee class having list of Employee objects.
Apply the Employee class to make and print employee hierarchy.
Verify the output.
Design Patterns Related Interview Questions
|Java Script Interview Questions||AJAX Interview Questions|
|Graphic Design Interview Questions||Adobe Indesign Interview Questions|
|Java-Multithreading Interview Questions||Database Design Interview Questions|
|Compiler Design Interview Questions||CSS Advanced Interview Questions|
|Java Design Patterns Interview Questions||Hardware design Interview Questions|
|Material Design Lite Interview Questions||Object Oriented Analysis and Design Interview Questions|
|Standard Template Library (STL) Interview Questions|
Design Patterns Tutorial
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.