Code Pumpkin

Category Archives: Interview Questions

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

The difference between interface and abstract class 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 between them. With support of default methods (introduced in Java8) and private methods (introduced in Java9) in interface, the gap between […]

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

Defining and Starting a Thread | Thread VS Runnable

Java threads are objects like any other Java objects. Threads are instances of class java.lang.Thread, or instances of subclasses of this class. In addition to being objects, java threads can also execute code. Creating and Starting Threads Here is the code to create a Thread and start its execution. // Creates Thread Object Thread thread = […]

UNION Vs UNION ALL | Oracle SQL

May 28, 2017
Posted by Pumpkin

Though both UNION and UNION ALL is used to combine results of two SELECT queries, the main difference between them is that UNION doesn't include duplicate records, but UNION ALL does. Another difference between them is that UNION ​ALL is faster than UNION , but may look slow because it returns more data which takes more […]

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

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

How does HashMap work internally in Java?

How does HashMap work internally in java is one of the most asked core java interview questions. Most of the candidates do not give the satisfactory explanation. This question shows that candidate has good knowledge of Collection. So this question should be in your TO-DO list before appearing for the interview. There are four things we should […]

How to create Immutable Class in Java

Immutable class is a class which once created, it's contents can not be changed. 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 create our own immutable class as well. Joshua Bloch's Effective Java has a very good explanation about why you […]

Previous Posts Next posts

Total Post : 80
Subscribe
Contribute Your Articles

Interview Experiences

Related Books

Like Us On Facebook

Alexa Page Rank