[Solved] Which of the following classes in java library do not implement a design pattern?


The official source for the Java standard library is the standard Java API documentation.

And one notable source for design patterns is the book Design Patterns: Elements of Reusable Object-Oriented Software.

To begin with, when you look at the options, the question (as quoted in your post) is badly formulated: “Which of the following classes in java library”

Only the fourth option (Proxy) can refer to a class in the Java standard library. The other three are NOT classes in the Java library (they are either interfaces or they don’t even exist as any type be it interface, class or enum). Also there are two Proxy classes in the Java library and this question doesn’t specify which one. Either the question was misundertood (and incorrectly rephrased) or you may want to mention this inconsistency to whoever composed it.

So the correct option may either be the fourth option, or may be none of them depending on which Proxy we consider.

So let’s take each option:

  1. Singleton: There is no class (or even type) with such name in the JDK standard library. Also, Singleton is a design pattern. So not this option.

  2. Observer: There is an interface (java.util.Observer) in the JDK, not a class. Also, Observer is a design pattern. So neither this one.

  3. Iterator: same as Observer. It’s an interface and refers to a design pattern.

  4. Proxy: There are two classes in the JDK. java.net.Proxy represents a network proxy setting, hardly ever related to the proxy design pattern. If this is the proxy that’s referred to, then the option is probably the correct one.

    If, on the other hand, we consider java.lang.reflect.Proxy which implements a dynamic proxy class that delegates method calls to other objects through an invocation handler, then this option would refer to a design pattern, making it not a correct option.

1

solved Which of the following classes in java library do not implement a design pattern?