CS FundamentalsHardGATE CS · TCS NQT Prime · Product Company SDE
A file-system explorer needs to treat individual files and whole folders (which may themselves contain files and folders) uniformly through the same interface, so client code can recurse without checking types. Which pattern fits?
- A. Decorator pattern
- B. Composite pattern
- C. Flyweight pattern
- D. Bridge pattern
Correct answer: B. Composite pattern
Composite lets individual objects (leaves) and compositions of objects (composites) be treated through a single common interface, which is exactly what lets a file-tree be walked uniformly regardless of whether a node is a file or a folder.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- A PERT activity has optimistic time 5 days, most likely time 10 days and pessimistic time 14 days. What is its expected duration, Te = (O…
- Two components with availability 99.9% and 98.0% are connected in series (the system works only if both are up). What is the system's…
- A company rents virtual machines, storage and networking from a provider but installs and manages its own operating system, runtime and…
- A system accepts a value from 10 to 109 inclusive. Using equivalence partitioning, what is the minimum number of test cases needed to…
- Why is a non-functional requirement (e.g. 'the system must respond within 200ms under 1000 concurrent users') often harder to verify than…
- A text editor needs to render a document containing a million characters without creating a million separate heavyweight glyph objects, by…