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 »

How to design Money Class in Java ?

In this post we will talk and learn How to design Money Class in Java  ?  Money is basically composed of two fundamental entities Amount and Currency. The BigDecimal is ideal data type provided in Java language for representing monetary values and Java also provides Currency Class implementation. Money class

Note: The code shown above… Read More »

How would you check if a number is even or odd using bit wise operator in Java?

In this post we will talk and learn How would you check if a number is even or odd using bit wise operator in Java? using an example. If you look carefully for all Odd numbers rightmost bit is always 1 in binary representation.

Notes We should prefer Bitwise operator for checking even or odd… Read More »