Prev Next

Java / Design Patterns

When to use Static Class in place of Singleton in Java?

If your Singleton is not maintaining any state, and just provide global access to methods, then consider using static class, as static methods are faster than Singleton, because of static binding during compile time.

It's right time to invest in Cryptocurrencies Dogecoin! Earn free bitcoins up to $250 now by signing up.

Earn bitcoins upto $250 (free), invest in other Cryptocurrencies when you signup with blockfi. Use the referral link: Signup now and earn!

Using BlockFi, don't just buy crypto - start earning on it. Open an interest account with up to 8.6% APY, trade currencies, or borrow money without selling your assets.


Join CoinBase! We'll both receive $10 in free Bitcoin when they buy or sell their first $100 on Coinbase! Available in India also. Use the referral Join coinbase!


Invest now!!! Get Free equity stock (US, UK only)!

Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.

The Robinhood app makes it easy to trade stocks, crypto and more.


Webull! Receive free stock by signing up using the link: Webull signup.

More Related questions...

What is design pattern in Java? What is Observer design pattern in Java? Name few design patterns used in standard JDK library in Java. Explain strategy design pattern in Java. Difference between Strategy and State design Pattern in Java. Singleton pattern. How to implement a singleton pattern? Why do we need Singleton class? (or) what are the advantages of using singleton pattern? What is Decorator pattern in Java? Give an example of Decorator pattern in Java. Difference between Decorator and Proxy pattern in Java. When to use Setter and Constructor Injection in Dependency Injection pattern? Explain Composite design Pattern in Java. Explain Front controller design pattern in Java/J2ee. Explain MVC design pattern in J2EE. How do you implement a thread-safe Singleton in Java? What is the difference between factory and abstract factory pattern in Java? Is Decorator an EJB design pattern in Java? Explain Facade design pattern. Types of Java Design patterns. Name few Creational Patterns in Java. Name some of the structural design patterns in Java. Name some of the Behavioral design patterns in Java. Explain Builder Design Pattern. Explain Factory pattern in Java. Difference between Service Provider Interface (SPI) and Application Programming Interface (API). Explain Service Provider framework pattern. Explain telescopic constructor pattern in Java. Explain Java beans pattern. Disadvantages of Java beans pattern. Explain builder pattern in Java. Disadvantage of Builder pattern. When to use Builder design pattern? In Java singleton, how do you prevent creating instance using reflection? How do we ensure Singleton Design Pattern in a clustered Environment? Difference between Singleton Pattern and static Class in Java. Give example of singleton class from JDK. When to use Static Class in place of Singleton in Java? Explain Bridge design pattern in Java. Explain prototype pattern in Java. Explain Template method design Pattern in Java. What is filter pattern in Java? Explain Proxy design pattern in Java. What is Adapter pattern in Java? Difference between the Bridge and Adapter pattern in Java. What is Chain of Responsibility Pattern in Java? Explain Intercepting Filter pattern in Java. Disadvantage of using factory pattern for object creation. Which pattern provides greater abstraction than factory pattern? Disadvantages of the singleton pattern. Which classes are candidates of Singleton? What is double checked locking in Singleton? How to prevent creating another instance of Singleton using clone() method? How to prevent creating another instance of Singleton during serialization? Explain mediator pattern in Java. Give few examples of Mediator Pattern in JDK. Explain Command design pattern in Java. What is State Design Pattern in Java? When cloning an object is preferred over creating a new object in Java? Name some of the design patterns that makes use of singleton pattern. Explain Memento pattern in Java. When do you use memento design pattern ? Explain visitor pattern in Java. What is value object design pattern? What is Transfer object design pattern in Java? Explain Service Locator design pattern in Java. Mention some of the core J2EE design patterns. Difference between Front Controller and View Helper in J2EE. Advantages of Factory method design pattern. What is a monolithic architecture? Is template method pattern an example of Inversion of control? Give an example of Template method pattern from JDK. Disadvantages of Immutable class. Types of messaging patterns. Difference between filter and interceptor patterns in Spring MVC.
Show more question and Answers...

Generics

Comments & Discussions