| 6. |
A developer argues that a class with only static methods and static fields achieves the same result as a Singleton. Which of the following best explains why the Singleton pattern is preferred over a purely static class?
Please select the correct answer:
|
| |
A.
|
A Singleton uses less memory than a static class because it does not allocate any fields. |
| |
B.
|
A Singleton can be subclassed and its single instance can be replaced with an instance of a subclass at runtime, whereas a purely static class cannot be subclassed in a useful way. |
| |
C.
|
A Singleton prevents all other objects from accessing its data, whereas a static class allows unrestricted access. |
| |
D.
|
A Singleton is always faster than a static class because it avoids the overhead of class loading. |