Continue with your mobile number
The Singleton Pattern ensures that a class has only one instance and provides a global point of access to it. It is often used for managing shared resources like a database connection pool, logging, or configuration settings. This pattern works by restricting the class's instantiation and providing a static method to get the single instance. Singleton is particularly useful when exactly one object is required to coordinate actions across the system. This pattern is implemented by making the constructor private, storing the single instance as a static property, and providing a public static method to access it. It ensures thread safety and lazy initialization in multi-threaded applications when implemented carefully. Explanation of Incorrect Options: A) Factory Pattern : The Factory Pattern focuses on creating objects without specifying their exact classes. It abstracts the instantiation process, allowing for flexibility in object creation. However, it does not restrict the number of instances or provide a global access point, making it unsuitable for the problem described. C) Observer Pattern : The Observer Pattern defines a one-to-many dependency between objects, where changes in one object are automatically reflected in dependent objects. It is ideal for event-driven systems but does not restrict the number of instances or provide global access, making it incorrect. D) Strategy Pattern : The Strategy Pattern allows behavior to be selected at runtime by encapsulating algorithms in separate classes. While it promotes flexibility, it does not deal with instance control or global access, making it irrelevant to the Singleton problem. E) Prototype Pattern : The Prototype Pattern involves creating new objects by copying existing ones rather than instantiating new ones. It is useful for object duplication but does not restrict the number of instances, hence it is not applicable here.
A reduction of 10% in the price of sugar enables a man to buy 5 kg more for RS 300. Find the reduced price per kg of sugar.
Axe and Wye purchases the Bikes at same price and later on Zed purchase both the bikes at the same price of Rs. 72000. But the profit % of Axe was A% wh...
The sum of the income of Raj and Roni is Rs. 168000. A spends 50% of his income and B spends 75% of his income in such a way that B’s saving is Rs. 90...
Marked price of an article is 1.45 times of cost price. Selling price is Rs. 1500.Find the discount percentage if profit percentage is 25%
An article is sold at a profit of 40%. If the purchasing price triples and the selling price decreases by 20%, what will be the percentage of profit or ...
An item is sold with a 30% discount on its marked price. As a result of this discount, the seller earns a profit of 40%. Given that the marked price of ...
A and B started a business with investments in the ratio 5:4 respectively. After 4 months, C joined them with an investment 30% more than the investment...
Suman sold two items, each for Rs. 2,500. She made a profit of 25% on the first item and incurred a loss of 16.67% on the second item. Calculate the tot...
A person bought an article and sold it at a loss of 25%. If he had bought it at 20% less and sold it for 63 more, he would have gained 20%. Find the pro...
A person buys books at Rs. 300 for 5 and sells them at Rs.740. How many books must he sell in order to earn profit of Rs. 3,520?