Builder Design Pattern is one of the commonly used design patterns. It falls under the category of Creational Design Patterns.
Factory Design Pattern is one of the most commonly used design patterns. It falls under the category of Creational Design Patterns.
Decorator design pattern is used to add a new feature on the existing object by wrapping it with a decorator class.
This problem is frequently asked in the interview to check your understanding on singleton design pattern. This program answers following artefacts of singleton design pattern:-
- How to make singleton class thread safe?
- using double checked locking
- How to prevent deserialization to create new object of singleton class?
- using readResolve method to return same instance
- How to prevent cloning to create a new object of singleton class?
- override clone method to return same instance
- How to prevent reflexion to create a new object of singleton class?
- check instance exist in private constructor and throw exception if already exist You can find the singleton pattern implementation here.
In this tutorial, we’ll learn about Immutable Class and its benefits in thread-safety, caching and collections. We will also look at rules to create immutable classes and eventually we’ll write an Immutable Class from scratch in Java.