Singleton
|
|
Título del Test:![]() Singleton Descripción: Information about Singleton |



| Comentarios |
|---|
NO HAY REGISTROS |
|
What is the primary purpose of the Singleton design pattern?. To create multiple, independent instances of a class for parallel processing. To ensure a class has only one universally accessible instance throughout the application's lifecycle. To define a family of related algorithms and encapsulate each one in a separate class. The Singleton pattern's main goal is to create a new instance of a class every time it is requested. True. False. The Singleton pattern is best described as a way to manage shared resources and maintain a consistent state across different parts of an application. True. False. What type of design pattern is the Singleton pattern classified as?. Structural pattern. Behavioral pattern. Creational pattern. When implemented correctly, the Singleton pattern ensures that all components of a software system interact with the exact same object instance in memory. True. False. Which phrase best describes the primary goal of the Singleton pattern in terms of access?. To provide flexible access points that can be easily swapped out with other instances. To establish a global point of access to the sole instance of a class. To hide the instance completely from external components. The definition of the Singleton pattern explicitly requires that a class must be capable of being instantiated into exactly one object. True. False. What is the key structural element that prevents a user from creating multiple instances of a Singleton class using the new keyword directly?. A public static method. A private constructor. A protected destructor. A Singleton class must use a public static variable to store the single instance of itself. True. False. What is the typical visibility and type of the method used to retrieve the sole instance of a Singleton class?. A private instance method (e.g., getInstance()). A public static method (e.g., getInstance()). A public instance method (e.g., getInstance()). The private static instance variable inside a Singleton class must be initialized when the class is loaded to ensure it is immediately available. True. False. Which component is responsible for checking if the instance already exists before creating a new one?. The private constructor. The client code calling the class. The public static access method. The structure of a Singleton is fundamentally about hiding the constructor and exposing a factory method for controlled instantiation. True. False. Which implementation variation creates the Singleton instance immediately when the class is loaded into memory by the system's class loader?. Lazy initialization. Eager initialization. Double-checked locking. It is appropriate to use the Singleton pattern when you need multiple independent game managers running simultaneously in different threads. True. False. When might a Singleton be justified as a design choice?. When managing user-specific session data in a multi-user environment. When a resource is genuinely singular in the entire system, like a single hardware driver or a central configuration registry. When a class needs to be easily scaled out across a distributed cluster of servers. Using a Singleton is a good practice if you anticipate a class might need multiple instances in the future to handle scalability requirements. True. False. You should generally avoid the Singleton pattern when: You need a central logging mechanism that all classes can access. You want to manage a single connection pool to a database. You are implementing business logic that requires different configurations based on context or user session. While Singletons ensure a single instance within a single Java Virtual Machine (JVM) or application process, they inherently manage uniqueness across a cluster of multiple physical machines. True. False. A software requirement specifies a system where the configuration manager must allow different modules to use different settings concurrently within the same application session. Is a Singleton an appropriate choice?. Yes. No. The use of Singletons often introduces tight coupling because client classes directly reference the concrete Singleton class within their code (e.g., calling MyConfig.getInstance()). True. False. When deciding whether to use a Singleton, a key consideration should be whether the logical constraint of "only one instance" is a technical requirement or a business requirement. Which type usually justifies using the pattern?. A business requirement. A technical requirement. Both are equally valid justifications. What is the very first step in the flow of operation when a client requests a Singleton instance using the getInstance() method for the first time (using lazy initialization)?. The private constructor is called immediately. The system checks if the internal static instance variable is null. The system checks if the internal static instance variable is null. Client code is responsible for manually destroying and recreating the Singleton instance when configuration changes are needed. True. False. |





