I had this question on my test:
What kind of programming / design pattern is this:
FileReader fr = new FileReader("file.txt"); BufferedReader bf = new BufferedReader(fr);
I’m sorry for the trouble, but definitions of programming patterns are unclear for me and I don’t know how to answer this question correctly.
That’s an example of the Decorator Pattern.
As the linked Wikipedia article states:
In your example, you’re adding buffering to a
FileReader, which provides more efficient reading than a regular, un-bufferedFileReader.