• 15 February

    Difference between process and thread in java

    In this tutorial, we are going to see differences between process and thread in java. If you are working on multithreading in java, it is good to know differences between process and thread. How multithreading can improve performance by executing code in parallel. Process vs Thread: The process can be referred as program in execution […]

  • 15 February

    Difference between throw and throws in java

    In this tutorial, we are going to see difference between throw and throws in java. throw: throw keyword is used to throw any custom exception or predefine exception. For example: Let’s say you want to throw invalidAgeException when employee age is less than 18. Create a Employee class as below. [crayon-676810ba1c9c4261487793/] Create InvalidAgeException class as […]

  • 14 February

    Difference between Serializable and Externalizable in Java

    In this tutorial,  we are going to see differences between Serializable and Externalizable interface in Java. Java Serialization Tutorial: Serialization in java Java Serialization interview questions and answers serialversionuid in java serialization externalizable in java Transient keyword in java Difference between Serializable and Externalizable in Java Before understanding difference, let me provide a short note on Serializable […]

  • 06 January

    Object level locking vs Class level locking in java

    Synchronization is ability to restrict access to shared resource to only one thread. When two or more threads need access to shared resource, there has to be some mechanism such that shared resource will be used by only one thread. The process by which we can achieve it is called Synchronization. Why do you need […]

  • 05 January

    Java newCachedThreadPool Example

    1. Introduction Java’s Executors.newCachedThreadPool() factory method provides a thread pool that creates new threads as needed, but will reuse previously constructed threads when they are available. Our goal is to understand how to use this thread pool to execute asynchronous tasks efficiently. 2. What is newCachedThreadPool? The newCachedThreadPool method from the java.util.concurrent.Executors class is a […]

  • 27 December

    Java ThreadPoolExecutor

    Java 5 has introduced new concurrent API called Executor frameworks to make programmer life easy. It simplifies design and development of multi-thread applications. It consists of mainly Executor, ExecutorService interface and ThreadPoolExecutor class which implements both interfaces i.e. Executor and ExecutorService. ThreadPoolExecutor class provide the implementation of thread pool. We will understand more about it […]

  • Immutable class interview questions
    22 December

    Immutable class interview questions

    In this post, I am going to share java interview questions which are generally asked on immutable class. Immutable class is important topic as it deals with creation of thread safe class. Here I am providing some important immutable class interview questions with answers. 1. What is immutable class? Answer : Immutable objects are those […]

  • 21 December

    How to create immutable class in java

    In this tutorial, we are going to see how to create immutable class in java. Immutable class is class whose state can not be changed once created. Example: String is best example for immutable class. Once you create a String, you can not change it. Immutable class is very simple to understand, it has only […]

  • 16 November

    OCAJP Encapsulation mock questions

    This is another post in the series of mock questions for . One of the exam objective is “Apply encapsulation principles to a class”. This exam objective tests your knowledge on how to write a class that meets the encapsulation principles and validate your understanding. I have prepared a set of good mock questions for […]