Code Pumpkin

Tag Archives: Java

Subscribe

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

Interface vs Abstract class in Java

July 7, 2017
Posted by Pumpkin

Interface has been evolved a lot in last two releases of java. Refer interface evolution in java for the same. However, there are still many differences between interface and abstract class. It is one of the most asked interview questions for entry level java developer interviews. Even though both are used to achieve abstraction in java, there are significant differences […]

Program to Check Whether a Number is Prime or Not

July 5, 2017
Posted by Pumpkin

Prime Number A prime number can be divided, without a remainder, only by itself and by 1. For example, 13 can be divided only by 13 and by 1, so it is a prime number. In other words, When the only two factors of a number are 1 and the number, then it is a Prime […]

Threadpool using Executor Framework | Java Concurrency Utilities

June 30, 2017
Posted by Pumpkin

The JDK 1.5 Executor framework is a combination of various Executor interfaces and Executors utility class to provide a thread pool feature in Java.  In server side programming, Thread pool is an important concept to maintain scalability, robustness, and stability of the system.   Thread pool is a pool of worker threads, which is ready to perform any task given to them, […]

Mediator Design Pattern

June 11, 2017
Posted by Pumpkin

Mediator Design Pattern is one of the Behavioral Design Pattern. With the Mediator Design Pattern, communication between objects is encapsulated with a mediator object. Objects no longer communicate directly with each other, but instead communicate through the mediator. This reduces the dependencies between communicating objects, thereby lowering the coupling. Definition GoF Definition: Define an object that encapsulates […]

Observer Design Pattern

June 7, 2017
Posted by Pumpkin

Observer Design Pattern is one of the Behavioral Design Pattern. Observer design pattern is useful when you are interested in the state of an object and want to get notified whenever there is any change.  Definition GoF Definition : The Observer Design Pattern defines a one-to-many dependency between objects so that when one object changes state, all […]

CountDownLatch Vs CyclicBarrier | Java Concurrency Utilities

CountDownLatch Vs CyclicBarrier : Though both are used as a synchronization aid that allows one or more threads to wait but there are certain differences between them that you should know in order to know when one of these utilities will serve you better.  As per the java.util.concurrent API,  CountDownLatch: A synchronization aid that allows one or more threads to […]

CyclicBarrier | Java Concurrency Utilities

May 25, 2017
Posted by Pumpkin

CyclicBarrier  was introduced in Java 5 along with other concurrent classes like CountDownLatch, ConcurrentHashMap, CopyOnWriteArrayList, BlockingQueue within java.util.Concurrent package. There are scenarios in concurrent programming when you want set of threads to wait for each other at a common point until all threads in the set have reached that common point.  The java.util.concurrent.CyclicBarrier class is a barrier that […]

InterruptedException in Java Multithreading

InterruptedException is thrown when a thread is waiting, sleeping, or otherwise occupied, and the thread is interrupted, either before or during the activity. Before reading this article, I recommend you to go through my article interrupt(), interrupted() and isInterrupted() in Java Multithreading. There are some methods in JDK that check the Interrupt status flag for us and throw InterruptedException, if it […]

interrupt(), interrupted() and isInterrupted() in Java Multithreading

In this post, we will understand about interrupt(), interrupted() and  isInterrupted() methods in Java Multithreading. If you are interested in reading more about interruption mechanism you can look into our post InterruptedException in Java Multithreading. In Java, thread starts its execution when we call start() method on Thread object. It internally calls overridden run() method. Thread is said to be terminated when […]

Previous Posts Next posts

Total Post : 82
Subscribe
Contribute Your Articles

Interview Experiences

Related Books

Like Us On Facebook

Alexa Page Rank