🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Design Patterns: all 10 questions

Quiz: Design Patterns · Question 9 of 10

Java I/O streams such as new BufferedReader(new FileReader(f)) add behaviour by wrapping. Which pattern is this?

Java I/O streams such as new BufferedReader(new FileReader(f)) add behaviour by wrapping. Which pattern is this?

  1. A.Singleton
  2. B.Factory
  3. C.Observer
  4. D.Decorator
Answer & explanation

Correct answer: Decorator

Each wrapper adds a feature (here buffering) around another object of the same kind.

Can you get the rest right without peeking?

Take the timed Quiz: Design Patterns quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →