What is BlockingQueue? How can we implement Producer and Consumer problem using Blocking Queue?

In this blog post we will talk and learn about one of the very important multi Threading Java interview question and question is that What is BlockingQueue? How can we implement Producer and Consumer problem using BlockingQueue? java.util.concurrent.BlockingQueue is a Queue that supports typically operations that wait for the queue to become non-empty when retrieving and… Read More »

Which classes in java are immutable ?

In this blog post we will talk and learn about one of very important java  interview question and question is that What are the classes in java are immutable ? Classes in java are immutable All wrapper classes are immutable – Boolean , Character, Byte, Short, Integer,Long, Float, Double Java.lang.String class is also Immutable Immutable classes… Read More »

How would you print a given currency value for Indian Locale (INR Currency)?

In this post we will talk and learn How would you print a given currency value for Indian Locale  (INR Currency) in java? NumberFormat class is designed specifically for this purpose. Currency symbol & Rounding Mode is automatically set based on the locale using NumberFormat. Lets see an example..

Output::  Amount = Rs.22.1215 You… Read More »

Which data type would you choose for storing currency values like Trading Price in Java?

In this post we will talk and learn  Which data type would you choose for storing currency values like Trading Price ? What is your opinion about Float, Double and BigDecimal data types ? Let’s see how double data type works for financial calculation

Sample output of above program: Total Amount = 20.19999999999996 The… Read More »

What do we understand by fair locks?

In this blog post we will talk and learn about one of very important multi Threading Java interview question and question is that What do we understand by fair locks? A fair lock takes the waiting time of the threads into account when choosing the next thread that passes the barrier to some exclusive resource. An… Read More »

Is it possible to check whether a thread holds a monitor lock on some given object?

In this blog post we will talk and learn about one of very important multi Threading Java interview question and question is that Is it possible to check whether a thread holds a monitor lock on some given object? We have method in class java.lang.Thread which provides the static method Thread.holdsLock(Object) that returns true if and only if the current… Read More »