Code Pumpkin

Category Archives: Interview Questions

Immutable class with mutable member fields in Java

April 30, 2018
Posted by Pumpkin

Immutable class is a class which once created, it's content can not be changed. Immutable classes are good choice for HashMap key as their state cannot be changed once they are created. Objects of immuable classes are also thread safe as threads can not change the value of its fields once it is created. Creating a basic immutable class is very […]

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 […]

Java Method Overriding Interview Questions

December 17, 2017
Posted by Pumpkin

In our previous article, we have discussed tricky programming questions based on method overloading. However, Method overriding programming questions are more interesting and requires depth understanding of the concept than that of method overloading. Before moving to programming questions, lets understand the basic concepts of method overriding. Method Overriding Using method overriding, child class can […]

Java Method Overloading Interview Questions

December 15, 2017
Posted by Pumpkin

After interviewing large set of candidates, we have come to conclusion that most of them fail to satisfactory explain basic OOPs concepts like difference between abstraction and encapsulation, static binding vs dynamic binding, co-varient return types, access modifiers scoping and checked exception handling in method overriding and overloading. Even if they are able to explain it well, interviewer […]

Marker Interface Interview Questions

December 12, 2017
Posted by Pumpkin

The interface in java is a mechanism to achieve abstraction and it is one of the most discussed topic in entry and mid level java developer interviews. In our previous articles, we have seen various interface related topics like Interface Evolution in Java, Difference between interface and abstract class and Functional interface in java 8. In this post, we are going to […]

What is magic number CAFEBABE in java class file?

November 29, 2017
Posted by Pumpkin

Java Compiler compiles a java source code into bytecode and stores it into .class file which will then get executed by JVM. Everybody knows about it. But do you know each class file in Java starts with magic number CAFEBABE?  compelling, isn't it? 😀  After reading this article, you will be able to answer below questions: […]

Trapping Rain Water | Algorithm Problem

October 29, 2017
Posted by Pumpkin

In this article, we are going to solve the trapping water problem. This kind of problems are asked very frequently in interviews and online programming challenges. Problem Statement We need to find the maximum volume of water that can be stored in between buildings or bars as shown in the below image. Assume that width of each […]

Previous Posts
Contribute Your Articles

Interview Experiences

Subscribe Us

Like Us On Facebook

Support Code Pumpkin on Patreon!