April 4, 2017


Observer Design Pattern

The observer pattern is a behavioral pattern and it expresses the dependency between objects. i.e one object and many dependent objects in such a way that when the state of one object changes all the dependent objects get notified. The objects which are watching the state change of the another object are called observers and that Read more about Observer Design Pattern[…]

Posted in blog | 11 Comments


Functional interface and Marker interface were close friends and one day night they were walking through a forest. They were scared as they knew the fact that anything dangerous can happen to them at any time in the forest.  Suddenly they saw a bear approaching them. Marker interface tried to pull the gun from his Read more about Lambda[…]

Posted in blog | 11 Comments


Student:              What happened Sir? No blogs now a days? Sir:                          I fell down from steps and there is a fracture on my right hand. So I cannot write till the plaster is removed. Student:              Oh…I’m sorry. Are you okay now? Sir:                          I’m fine. Only some difficulties as I cannot use my right hand now. Read more about finalize()[…]

Posted in blog | 21 Comments

Shallow vs Deep comparison of objects

Mary : “Which car you own?” Lucy : “I have FIAT 500X” Mary : “Hey…we have same car. I too have FIAT 500X”   You must have heard about comparing two objects in Java using == and equals() method. What is the difference ? Or what is the difference between deep and shallow comparison ? Read more about Shallow vs Deep comparison of objects[…]

Posted in blog | 11 Comments

Decorator Design Pattern

Henry went to the restaurant and ordered one chicken biriyani. After 5 minutes the waiter brought the biriyani. Once when started eating Henry noticed that there is an egg in the biriyani along with two chicken pieces. Thinking that the waiter would have put that egg by mistake Henry called him and told, “I ordered Read more about Decorator Design Pattern[…]

Posted in blog | 20 Comments

Scope of variables in Java

void doStuff() {       for (int i = 0; i < 4; i++) {            boolean flag = false;            if (i == 3) { flag = true; } } System.out.println(flag); } I’m sure the compiler will do this : Compiler will say that I have no memory Read more about Scope of variables in Java[…]

Posted in blog | 10 Comments


Thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an instance. — Official statement. A guaranteed ClassCastException 😀     ClassCastException is a runtime exception belongs to java.lang package.   Object in = 10; String s = (String)in;   The above code compiles but Read more about ClassCastException[…]

Posted in blog | 6 Comments


  An object asks “Whenever I’m created, I stay in the heap memory.  Is it possible for you to persist me somewhere? ” Yes it is possible. An object and its instance variables can be saved into a physical device. Object serialization saves the state of an object as sequence of bytes and at later Read more about Serialization[…]

Posted in blog | 8 Comments