A GeneralPath collects shapes and is itself a shape. What design pattern does it exemplify?
Ans ).
Composite Pattern.
because if you remember composite pattern condition which says "Clients treat a composite object as a primitive object.". Here primitive object means the root object itself, which in our case is shape. That is A generalPath collects shape(a composite object) ans is itself a shape (as a primitive object). Therefore, it is definitely Compostion Pattern.
Hope it helped! Feel free to ask any doubt in comments. Don't forget to upvote if it helped :).
Get Answers For Free
Most questions answered within 1 hours.