Code Pumpkin

Tag Archives: Creational Design Patterns

Breaking Singleton using reflection and Enum Singleton

This is our fifth article in the series of Singleton Design Pattern. The purpose of the singleton class is to control object creation, limiting the number of objects to only one. In our previous articles, we have discussed how we can create Singleton Design Pattern in Single-threaded and multithreaded environment. We have also discussed how we can […]

Preventing Cloning in Singleton Design Pattern

This is our third article on Singleton Design Pattern. The purpose of the singleton class is to control object creation, limiting the number of objects to only one. In our previous two articles, we have discussed how we can create Singleton Design Pattern in Single-threaded and multithreaded environment. In this article, we will discuss how we can […]

Serialization and Singleton Design Pattern

This is our forth article in the series of Singleton Design Pattern Articles. The purpose of the singleton class is to control object creation, limiting the number of objects to only one.  In our previous three articles, we have discussed how we can create Singleton Design Pattern in Single-threaded and multithreaded environment. We have also discussed how […]

Singleton Design Pattern Using Double Checked Locking

This is our second article in the series of Singleton Design Pattern.  In this article, we will see different thread safe approaches for lazy Initialization Singleton Design Pattern like Using Synchronized getInstance() method, Double checked locking approach and Bill Pugh Implementation using Inner class. For navigating to the other articles on Singleton Design Pattern, please refer table of contents on the right […]

Sapient Global Markets Interview Questions – Set 2

September 12, 2017
Posted by Rama Prasad

I applied for Junior Associate position (Java Developer) at Sapient Bangalore location. This was my second technical round with Sapient Global Markets, Bangalore. It was Skype interview.  You can also read my article for the interview experience of first technical round at Sapient.  From my interview experience with Sapient, I can say that their interviewers have some […]

Object Pool Design Pattern

July 29, 2017
Posted by Dipen Adroja

Object pool design pattern is one of the Creational Design Pattern. In very simple term, this design pattern means To Reuse the objects which are very costly to create. Object pooling is creating objects of the class at the time of creation and put them into one common pool. Now whenever application needs object of that class […]

What is the use of private constructor in java?

In Java, we can use any access modifier (i.e. public, protected or private) with constructor.  So, what are the uses of making constructor private? First thing that strikes your mind is Singleton Design Pattern which is also one of the most asked Core Java Interview Question to the 3-4 yr exp Java developers.  Apart from creating singleton class, private constructor […]

Builder Design Pattern

April 27, 2017
Posted by Abhi Andhariya

Builder design pattern is a creational design pattern like Factory Pattern and Abstract Factory Pattern. For better understanding of  any  design pattern, You should know the problems faced by programmers before that design pattern was introduced. What are the traditional ways of creating an object of a class? We can provide either constructor or a static factory method to get the object  of […]

How to create Immutable Class in Java

Immutable class is a class which once created, it's contents can not be changed. In other words, Immutable objects are the objects whose state can not be changed once constructed.  In Java, String and all the wrapper classes e.g. Boolean, Integer, Long, etc are immutable classes. We can also create our own immutable class.  Why should we write Immutable Classes? Here are […]

Singleton Design Pattern

In Design Pattern article, we have seen different types of design patterns. In this article, we will understand one of the simplest Creational Design Pattern i.e. Singleton Design Pattern. What is the purpose of Singleton? The purpose of the singleton class is to control object creation, limiting the number of objects to only one. The singleton allows only […]

Previous Posts
Total Posts : 124
follow us in feedly

Like Us On Facebook